fork download
  1.  
  2. #version 330 core
  3.  
  4. // Input vertex data, different for all executions of this shader.
  5. layout(location = 0) in vec3 vertexPosition_modelspace;
  6. layout(location = 1) in vec2 vertexUV;
  7. layout(location = 2) in vec3 vertexNormal_modelspace;
  8.  
  9. // Output data ; will be interpolated for each fragment.
  10. out vec2 UV;
  11. out vec3 Position_worldspace;
  12. out vec3 Normal_cameraspace;
  13. out vec3 EyeDirection_cameraspace;
  14. out vec3 LightDirection_cameraspace;
  15.  
  16. // Values that stay constant for the whole mesh.
  17. uniform mat4 MVP;
  18. uniform mat4 V;
  19. uniform mat4 M;
  20. uniform vec3 LightPosition_worldspace;
  21.  
  22. void main(){
  23.  
  24. // Output position of the vertex, in clip space : MVP * position
  25. gl_Position = MVP * vec4(vertexPosition_modelspace,1);
  26.  
  27. // Position of the vertex, in worldspace : M * position
  28. Position_worldspace = (M * vec4(vertexPosition_modelspace,1)).xyz;
  29.  
  30. // Vector that goes from the vertex to the camera, in camera space.
  31. // In camera space, the camera is at the origin (0,0,0).
  32. vec3 vertexPosition_cameraspace = ( V * M * vec4(vertexPosition_modelspace,1)).xyz;
  33. EyeDirection_cameraspace = vec3(0,0,0) - vertexPosition_cameraspace;
  34.  
  35. // Vector that goes from the vertex to the light, in camera space. M is ommited because it's identity.
  36. vec3 LightPosition_cameraspace = ( V * vec4(LightPosition_worldspace,1)).xyz;
  37. LightDirection_cameraspace = LightPosition_cameraspace + EyeDirection_cameraspace;
  38.  
  39. // Normal of the the vertex, in camera space
  40. Normal_cameraspace = ( V * M * vec4(vertexNormal_modelspace,0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not.
  41.  
  42. // UV of the vertex. No special space for this one.
  43. UV = vertexUV;
  44. }
  45.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Вершинный шейдер
compilation info
prog.cpp:2:2: error: invalid preprocessing directive #version
 #version 330 core
  ^~~~~~~
prog.cpp:5:7: error: expected constructor, destructor, or type conversion before ‘(’ token
 layout(location = 0) in vec3 vertexPosition_modelspace;
       ^
prog.cpp:6:7: error: expected constructor, destructor, or type conversion before ‘(’ token
 layout(location = 1) in vec2 vertexUV;
       ^
prog.cpp:7:7: error: expected constructor, destructor, or type conversion before ‘(’ token
 layout(location = 2) in vec3 vertexNormal_modelspace;
       ^
prog.cpp:10:1: error: ‘out’ does not name a type
 out vec2 UV;
 ^~~
prog.cpp:11:1: error: ‘out’ does not name a type
 out vec3 Position_worldspace;
 ^~~
prog.cpp:12:1: error: ‘out’ does not name a type
 out vec3 Normal_cameraspace;
 ^~~
prog.cpp:13:1: error: ‘out’ does not name a type
 out vec3 EyeDirection_cameraspace;
 ^~~
prog.cpp:14:1: error: ‘out’ does not name a type
 out vec3 LightDirection_cameraspace;
 ^~~
prog.cpp:17:1: error: ‘uniform’ does not name a type
 uniform mat4 MVP;
 ^~~~~~~
prog.cpp:18:1: error: ‘uniform’ does not name a type
 uniform mat4 V;
 ^~~~~~~
prog.cpp:19:1: error: ‘uniform’ does not name a type
 uniform mat4 M;
 ^~~~~~~
prog.cpp:20:1: error: ‘uniform’ does not name a type
 uniform vec3 LightPosition_worldspace;
 ^~~~~~~
prog.cpp:22:11: error: ‘::main’ must return ‘int’
 void main(){
           ^
prog.cpp: In function ‘int main()’:
prog.cpp:25:2: error: ‘gl_Position’ was not declared in this scope
  gl_Position =  MVP * vec4(vertexPosition_modelspace,1);
  ^~~~~~~~~~~
prog.cpp:25:17: error: ‘MVP’ was not declared in this scope
  gl_Position =  MVP * vec4(vertexPosition_modelspace,1);
                 ^~~
prog.cpp:25:28: error: ‘vertexPosition_modelspace’ was not declared in this scope
  gl_Position =  MVP * vec4(vertexPosition_modelspace,1);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:25:55: error: ‘vec4’ was not declared in this scope
  gl_Position =  MVP * vec4(vertexPosition_modelspace,1);
                                                       ^
prog.cpp:28:2: error: ‘Position_worldspace’ was not declared in this scope
  Position_worldspace = (M * vec4(vertexPosition_modelspace,1)).xyz;
  ^~~~~~~~~~~~~~~~~~~
prog.cpp:28:25: error: ‘M’ was not declared in this scope
  Position_worldspace = (M * vec4(vertexPosition_modelspace,1)).xyz;
                         ^
prog.cpp:32:2: error: ‘vec3’ was not declared in this scope
  vec3 vertexPosition_cameraspace = ( V * M * vec4(vertexPosition_modelspace,1)).xyz;
  ^~~~
prog.cpp:33:9: error: ‘EyeDirection_cameraspace’ was not declared in this scope
         EyeDirection_cameraspace = vec3(0,0,0) - vertexPosition_cameraspace;
         ^~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:33:50: error: ‘vertexPosition_cameraspace’ was not declared in this scope
         EyeDirection_cameraspace = vec3(0,0,0) - vertexPosition_cameraspace;
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:36:7: error: expected ‘;’ before ‘LightPosition_cameraspace’
  vec3 LightPosition_cameraspace = ( V * vec4(LightPosition_worldspace,1)).xyz;
       ^~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:37:2: error: ‘LightDirection_cameraspace’ was not declared in this scope
  LightDirection_cameraspace = LightPosition_cameraspace + EyeDirection_cameraspace;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:37:31: error: ‘LightPosition_cameraspace’ was not declared in this scope
  LightDirection_cameraspace = LightPosition_cameraspace + EyeDirection_cameraspace;
                               ^~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:40:2: error: ‘Normal_cameraspace’ was not declared in this scope
  Normal_cameraspace = ( V * M * vec4(vertexNormal_modelspace,0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not.
  ^~~~~~~~~~~~~~~~~~
prog.cpp:40:25: error: ‘V’ was not declared in this scope
  Normal_cameraspace = ( V * M * vec4(vertexNormal_modelspace,0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not.
                         ^
prog.cpp:40:38: error: ‘vertexNormal_modelspace’ was not declared in this scope
  Normal_cameraspace = ( V * M * vec4(vertexNormal_modelspace,0)).xyz; // Only correct if ModelMatrix does not scale the model ! Use its inverse transpose if not.
                                      ^~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:43:2: error: ‘UV’ was not declared in this scope
  UV = vertexUV;
  ^~
prog.cpp:43:7: error: ‘vertexUV’ was not declared in this scope
  UV = vertexUV;
       ^~~~~~~~
stdout
Standard output is empty