Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* === YOUR WORK HERE ===
  2.  * Vertex shader: you need to edit the code here!
  3.  * First, you need to understand the Java program,
  4.  * mainly understand how the variables in this shader program
  5.  * are associated with buffers and variables defined
  6.  * in your Java program.
  7.  * The main changes you need to do here is to use the 'TINVMV' matrix
  8.  * to properly transform vertex normals, compute light vectors
  9.  * that you will use for diffuse shading, pass the uv coordinates down the pipeline.
  10.  */
  11. #version 330
  12.  
  13. layout(location = 0) in vec4 vertex_pos;    // https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)
  14. layout(location = 1) in vec3 vertex_normal;
  15. layout(location = 2) in vec2 uv_coordinates;
  16.  
  17. uniform mat4 MVP;
  18. uniform mat4 MV;
  19. uniform mat4 TINVMV;
  20. uniform vec4 light0_pos_eye;
  21.  
  22. out vec2 uv_coordinates_raster;
  23. out vec3 normals_raster;
  24. out vec3 light0_vector_raster;
  25.  
  26. void main()
  27. {  
  28.     gl_Position = MVP * vertex_pos;
  29.    
  30.     // you need to change the following lines!
  31.     uv_coordinates_raster = uv_coordinates;
  32.     normals_raster = normalize(vec3(mat3(TINVMV) * vertex_normal));
  33.     light0_vector_raster = normalize(vec3(light0_pos_eye - (MV * vertex_pos)));
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement