水下效果
来源:互联网 发布:powerbi连接数据库 编辑:程序博客网 时间:2024/04/28 01:21
这里说的水下效果, 是指在水底下时, 为了增强真实感, 做的一种水的波动效果, 算是post process的一种吧
原理很简单, 就是把渲染好的屏幕场景做为一张纹理输入, 然后对上面的像素按时间进行扰动, 这样感觉好像水在晃动一样, 增强代入感. (想想潜水时^_^)
代码很简单, 没啥好说的
struct VS_OUTPUT
{
float4 pos : POSITION0;
float2 texCoord : TEXCOORD0;
};
float fTime0_1;
VS_OUTPUT vs_main( float4 inPos: POSITION )
{
VS_OUTPUT o = (VS_OUTPUT) 0;
inPos.xy = sign( inPos.xy);
o.pos = float4( inPos.xy, 0.0f, 1.0f);
// get into range [0,1]
o.texCoord = (float2(o.pos.x, -o.pos.y) + 1.0f)/2.0f;
return o;
}
sampler2D Texture0;//屏幕RenderTarget
sampler2D Texture1;//扰动纹理
float fTime0_1;
float4 ps_main( float2 texCoord : TEXCOORD0 ) : COLOR
{
float2 bump = tex2D(Texture1, texCoord + (fTime0_1*20));
float2 texel = texCoord + bump/500;
return tex2D( Texture0, texel );
}
Texture1是一张bumpmap
最终效果:
可能不太明显, 毕竟是个动态效果, 把波动值加大:
关于扰动的时候屏幕边缘会显示另一边的像素的问题, 只要把texture0的寻址模式改成CLAMP就OK啦
- 水下效果
- 水下模糊效果
- unity水下模糊效果
- 实现简单的水下效果
- [Android实例] 水下气泡上升界面效果
- 墙纸教程–精美水下效果
- android 水下气泡上升界面效果
- unity3d 实现简单的水下相机效果脚本代码
- 水下文字
- 第五天,终于实现了水下模糊效果(动态挂载脚本),blur里写入shader
- unity3d 简单水下特效
- 水下常用参数
- 水下救人 经验
- 水下无线充电设想
- 摄影:水下拍(好玩)
- 水下图像采集
- 水下图像增强
- hdu 2149 博弈 水下去
- Using a Custom Action to Create a Database During Installation
- 访企业工作流管理专家胡长城有感
- 自定义公式的计算处理
- 我的日記 2008/04/10 設定datagrid 的title
- 了解知识产权 先从自身做起
- 水下效果
- 在单元测试中使用EasyMock
- Querying XML Data with XQuery
- 深入浅出话友元
- Google打不开的解决方法和IP地址表
- 动态关联表
- 小试一把 64 位 Windows 编程
- 矿泉水网络又一天:思考网络媒体的自由度
- Struts2.0: Web开发的精灵框架