ShadowVolVertShader.vsh 757 B

12345678910111213141516171819202122232425262728
  1. /*
  2. The vertex shader used for extruding the shadow volume along the light
  3. direction. If inExtrude is > 0 then the vertex of the shadow volume is
  4. extruded along the light direction by VolumeScale. If it is 0 then
  5. the vertex position is calculated as normal.
  6. */
  7. attribute highp vec3 inVertex;
  8. attribute lowp float inExtrude;
  9. uniform highp mat4 MVPMatrix;
  10. uniform highp vec3 LightPosModel;
  11. uniform mediump float VolumeScale;
  12. void main()
  13. {
  14. if (inExtrude > 0.0)
  15. {
  16. mediump vec3 lightDir = normalize(inVertex - LightPosModel);
  17. mediump vec3 extrudedPos = inVertex + (VolumeScale * lightDir);
  18. gl_Position = MVPMatrix * vec4(extrudedPos, 1.0);
  19. }
  20. else
  21. {
  22. gl_Position = MVPMatrix * vec4(inVertex, 1.0);
  23. }
  24. }