Real-Time Glow

博客介绍了glow效果,即对象旁出现光晕且看起来更亮。还阐述了产生glow的简单方法,包括按通常模式渲染场景、只渲染带glow效果物体到纹理、对纹理做模糊处理、将处理后的纹理贴到屏幕上,最后给出了详细资料及渲染例子链接。
Real-Time Glow
原出处:  http://xreal.51.net/Game/realtimeglow.htm

   所谓的glow,就是在一个对象旁边出现一些光晕.通常一个自身能发光或者相对场景中其它比较暗的物体来说,都会产生这种现象的。而且,这些对象看起来都会比自身更加亮一些.
 其实要产生glow很简单.我在这里简单的描述一下:


  1:按通常的模式渲染场景.


  2:只渲染带有glow效果的物体.这时候,我们把它渲染到一张纹理里去,这张纹理可以比viewPort小.渲染的时候,我们不再使用diffuse信息,而是使用glow信息.比如一个人物,我们可能希望他脸部带的glow重一些.而其他地方小一些.一个大楼的话,亮着灯的地方有glow.而其他的地方没有.我们可以把这些信息保存在普通的diffuse纹理里(用diffuse本身,或者alpha通道)也可以采用专用的glow信息纹理.渲染完成这个纹理后,纹理里保存的是有glow物体才屏幕上的额外亮度信息.


 3:对2中的纹理做blur,沿x-y方向做一定程度的模糊.使本来只在物体的上的glow信息向两边扩散.当然,也可以在渲染2的时候,把物体沿法线方向拉伸.(我两种方法都用了).

 4:最后把经过步骤3处理后的纹理贴到屏幕上,也就是把glow信息加回到场景中.用add的方式应用纹理.


   详细的real-time glow,见GPU Gems

   以下是我用renderMonkey渲染的例子

http://xreal.51.net/Download/RTGlow.rar

http://xreal.51.net/Game/glow/glow1.jpg

http://xreal.51.net/Game/glow/glow2.jpg

http://xreal.51.net/Game/glow/glow3.jpg


 xheartblue-2005-3-7

<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <title>音频同步歌词</title> <style> .container { font-family: Arial, sans-serif; max-width: 600px; margin: 20px auto; padding: 20px; text-align: center; } #audioPlayer { width: 100%; margin-bottom: 20px; } #lyrics { color: #333; line-height: 2; font-size: 18px; min-height: 60px; padding: 10px; } .highlight { color: red; font-weight: bold; background-color: rgba(255, 255, 0, 0.3); border-radius: 4px; padding: 2px 4px; } </style> </head> <body> <div class="container"> <!-- 音频播放器 --> <audio id="audioPlayer" controls> <source src="your-audio.mp3" type="audio/mpeg"> 您的浏览器不支持 audio 元素。 </audio> <!-- 歌词显示区域 --> <div id="lyrics">播放后将显示歌词...</div> </div> <script> // 获取音频元素和歌词容器 const audio = document.getElementById("audioPlayer"); const lyricsDiv = document.getElementById("lyrics"); // 定义歌词及其出现的时间(单位:秒) const lyrics = [ { time: 0.0, text: "I will run, I will climb, I will soar" }, { time: 4.0, text: "I’m undefeated" }, { time: 8.0, text: "Jumping out of my skin, pull the chord" }, { time: 12.0, text: "Yeah I believe it" }, { time: 16.0, text: "The past, is everything we were don’t make us who we are" }, { time: 20.0, text: "So I’ll dream, until I make it real, and all I see is stars" }, { time: 24.0, text: "It's not until you fall that you fly" }, { time: 28.0, text: "When your dreams come alive you’re unstoppable" }, { time: 32.0, text: "Take a shot, chase the sun, find the beautiful" }, { time: 36.0, text: "We will glow in the dark turning dust to gold" }, { time: 40.0, text: "And we’ll dream it possible possible And we'll dream it possible" }, { time: 44.0, text: "I will chase, I will reach, I will fly" }, { time: 48.0, text: "Until I’m breaking, until I’m breaking" }, { time: 52.0, text: "Out of my cage, like a bird in the night" }, { time: 56.0, text: "I know I’m changing, I know I’m changing" }, { time: 60.0, text: "In, into something big, better than before" }, { time: 64.0, text: "And if it takes, takes a thousand lives" }, { time: 68.0, text: "Then it’s worth fighting for" }, { time: 72.0, text: "It's not until you fall that you fly" }, { time: 76.0, text: "When your dreams come alive you’re unstoppable" }, { time: 80.0, text: "Take a shot, chase the sun, find the beautiful" }, { time: 84.0, text: "We will glow in the dark turning dust to gold" }, { time: 88.0, text: "And we’ll dream it possible it possible" }, { time: 92.0, text: "From the bottom to the top" }, { time: 96.0, text: "We’re sparking wild fires" }, { time: 100.0, text: "Never quit and never stop" }, { time: 104.0, text: "The rest of our lives" }, { time: 108.0, text: "From the bottom to the top" }, { time: 112.0, text: "We’re sparking wild fires" }, { time: 116.0, text: "Never quit and never stop" }, { time: 120.0, text: "It's not until you fall that you fly" }, { time: 124.0, text: "When your dreams come alive you’re unstoppable" }, { time: 128.0, text: "Take a shot, chase the sun, find the beautiful" }, { time: 132.0, text: "We will glow in the dark turning dust to gold" }, { time: 136.0, text: "And we’ll dream it possible possible And we'll dream it possible" } ]; // 当音频播放或时间更新时触发 audio.addEventListener("timeupdate", () => { const currentTime = audio.currentTime; // 找到当前应显示的最新一行歌词 let currentLine = null; for (let i = lyrics.length - 1; i >= 0; i--) { if (currentTime >= lyrics[i].time) { currentLine = lyrics[i]; break; } } // 显示当前行并高亮 if (currentLine) { lyricsDiv.innerHTML = `<span class="highlight">${currentLine.text}</span>`; } else { lyricsDiv.textContent = "正在加载歌词..."; } }); // 播放结束时重置 audio.addEventListener("ended", () => { lyricsDiv.textContent = "播放结束"; }); </script> </body> </html>帮我改写代码,使歌词和音频同步
最新发布
10-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值