- 最近情绪有点消沉,状态不佳就不写太多了.Dislace Mapping其实就是在顶点着色器中
- 对顶点进行置换偏移,经常用于水仿真流体绘制.
- 顶点着色器:
- uniform float g_fScale;
- uniform sampler2D g_DisplaceTexture;
- void main()
- {
- float fDisplace = texture2DLod(g_DisplaceTexture, gl_MultiTexCoord0.st, 0.0).r;
- vec4 vec4NewVertex = vec4(gl_Vertex.x, gl_Vertex.y + g_fScale*fDisplace, gl_Vertex.zw);
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = gl_ModelViewProjectionMatrix*vec4NewVertex;
- }
- 片元着色器:
- uniform sampler2D g_DecalTexture;
- void main()
- {
GLSL实现Simple Displace Mapping
最新推荐文章于 2021-03-21 16:52:11 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)