cookyt

Shadow map vertex shader

Nov 27th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. precision mediump float;
  2.  
  3. attribute vec3 position;
  4. attribute vec3 normal;
  5. attribute vec2 tex_coord;
  6.  
  7. // Perspective * View * Model
  8. uniform mat4 scene_mat;
  9.  
  10. uniform mat4 model_mat;
  11.  
  12. // transpose(inverse(Model))
  13. uniform mat4 normal_mat;
  14.  
  15. uniform int has_diffuse;
  16.  
  17. // Interpolated vertex properties
  18. varying vec3 var_position; // world-space position
  19. varying vec3 var_normal;
  20. varying vec2 var_tex_coord;
  21.  
  22. void main() {
  23.   gl_Position = scene_mat * vec4(position, 1.0);
  24.  
  25.   var_position = (model_mat * vec4(position, 1.0)).xyz;
  26.   var_normal = (normal_mat * vec4(normal, 1.0)).xyz;
  27.   if (has_diffuse != 0)
  28.     var_tex_coord = tex_coord;
  29.   else
  30.     var_tex_coord = vec2(0);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment