SkyboxVShader.vsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. attribute mediump vec3 inVertex;
  2. uniform mediump mat4 ModelMatrix;
  3. uniform mediump mat4 ModelViewMatrix;
  4. uniform mediump mat4 MVPMatrix;
  5. #ifdef ENABLE_FOG_DEPTH
  6. uniform mediump float WaterHeight; //Assume water always lies on the y-axis
  7. #endif
  8. #ifdef ENABLE_DISCARD_CLIP
  9. uniform bool ClipPlaneBool;
  10. uniform mediump vec4 ClipPlane;
  11. #endif
  12. varying mediump vec3 EyeDir;
  13. #ifdef ENABLE_FOG_DEPTH
  14. varying mediump float VertexDepth;
  15. #endif
  16. #ifdef ENABLE_DISCARD_CLIP
  17. varying highp float ClipDist;
  18. #endif
  19. void main()
  20. {
  21. EyeDir = -inVertex;
  22. gl_Position = MVPMatrix * vec4(inVertex, 1.0);
  23. #ifdef ENABLE_DISCARD_CLIP
  24. // Compute the distance between the vertex and clipping plane (in world space coord system)
  25. mediump vec4 vVertexView = ModelMatrix * vec4(inVertex.xyz,1.0);
  26. ClipDist = dot(vVertexView, ClipPlane);
  27. #endif
  28. #ifdef ENABLE_FOG_DEPTH
  29. // Calculate the vertex's distance under water surface. This assumes clipping has removed all objects above the water
  30. mediump float vVertexHeight = (ModelMatrix * vec4(inVertex,1.0)).y;
  31. VertexDepth = WaterHeight - vVertexHeight;
  32. #endif
  33. }