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

推荐订阅源

Engineering at Meta
Engineering at Meta
G
Google Developers Blog
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
T
The Blog of Author Tim Ferriss
I
InfoQ
MyScale Blog
MyScale Blog
V
V2EX
B
Blog
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 邗影

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 视频
  • 叶片上的视频随开合变暗/变亮,并有轻微倾斜