oceanGLSL.vert
资源名称:3dwind2.0.rar [点击查看]
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:1k
源码类别:
游戏引擎
开发平台:
Visual C++
- // oceanGLSL.vert
- // vertex program for Ocean water simulation
- // 05 Aug 2005
- // adapted for Ogre by nfz
- // converted from HLSL to GLSL
- // original shader source from Render Monkey 1.6 Reflections Refractions.rfx
- // 06 Aug 2005: moved uvw calculation from fragment program into vertex program
- uniform vec3 scale;
- uniform vec3 eyePosition;
- uniform vec2 waveSpeed;
- uniform float noiseSpeed;
- uniform float time_0_X;
- varying vec3 uvw;
- varying vec3 normal;
- varying vec3 vVec;
- void main(void)
- {
- gl_Position = ftransform();
- // uvw is the calculated uvw coordinates based on vertex position
- // GLSL uses xy instead of xz for uv and z is depth so do some swizzling
- vec3 lookupPos = gl_Vertex.xzy * scale.xzy;
- lookupPos .x += waveSpeed.x * time_0_X;
- lookupPos .y += waveSpeed.y * time_0_X;
- lookupPos .z += lookupPos.y + noiseSpeed * time_0_X;
- uvw = lookupPos;
- // the view vector needs to be in vertex space
- vVec = gl_Vertex.xyz - eyePosition;
- normal = gl_Normal;
- }