惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
博客园 - 司徒正美
罗磊的独立博客
D
Docker
Last Week in AI
Last Week in AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
V2EX
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 叶小钗
B
Blog RSS Feed
A
About on SuperTechFans
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
P
Proofpoint News Feed

博客园 - 邗影

TOF传感器 3D融合场景demo 传感器 关于音频PA结构腔体 球面渲染 关于linux和shi脚本常用的通配符 关于fread读不满一块和读不满count的返回值 如何去掉merge UBI的覆盖写和擦除 DTSI 多个模块共用同一个 GPIO 引脚冲突 问题汇总 debug比release程序启动的快 关于CPU占用优先级的调整 关于蜂鸣器发声 麦序与声源定位 关于squashfs压缩挂载 软连接生成 线程退出未定义行为 linux文件查找 C语言弱函数 数据传输报错port unreachable D3D11绘制三角形 关于延迟测试 v4l2检测 关于数据库的性能 流媒体小记包含一些面试问题 v4l2视频采集 流媒体ZLM配置vscode远程开发 关于SPS中的帧率问题 Linux编译问题 SSl冲突问题
opengl渲染YUV的波浪百叶窗效果
邗影 · 2026-08-20 · via 博客园 - 邗影
接上一篇---3D融合场景demo - 邗影 - 博客园
#version 330 core in vec2 TexCoord; out vec4 FragColor; uniform sampler2D yTexture; uniform sampler2D uvTexture; uniform float time;//new
//
void main() { float blinds = 16.0; float stripId = floor(TexCoord.y * blinds); float stripFract = fract(TexCoord.y * blinds); float phase = stripId * 0.6; float openness = (sin(time * 1.5 + phase) + 1.0) * 0.5; // 0.0 ~ 1.0 float slatWidth = 0.2 + 0.6 * openness; if (stripFract > slatWidth) { float y = texture(yTexture, TexCoord).r; float u = texture(uvTexture, TexCoord).r - 0.5; float v = texture(uvTexture, TexCoord).g - 0.5; float r = y + 1.402 * v; float g = y - 0.344136 * u - 0.714136 * v; float b = y + 1.772 * u; FragColor = vec4(r, g, b, 1.0); return; } float tilt = (1.0 - openness) * 0.04 * (mod(stripId, 2.0) * 2.0 - 1.0); vec2 sampleUV = TexCoord + vec2(tilt, 0.0); float y = texture(yTexture, sampleUV).r; float u = texture(uvTexture, sampleUV).r - 0.5; float v = texture(uvTexture, sampleUV).g - 0.5; float r = y + 1.402 * v; float g = y - 0.344136 * u - 0.714136 * v; float b = y + 1.772 * u; float dim = 0.5 + 0.5 * openness; FragColor = vec4(r * dim, g * dim, b * dim, 1.0); }

yuvShader.setFloat("time", static_cast<float>(glfwGetTime()));

  • sin(time * 1.5 + phase) 让每片叶片周期性开合
  • phase = stripId * 0.6 让相邻叶片错开相位,形成波浪
  • 缝隙处直接透出完整 YUV 视频
  • 叶片上的视频随开合变暗/变亮,并有轻微倾斜