Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330 core
- // Input vertex data, different for all executions of this shader.
- layout(location = 0) in vec3 position_modelspace;
- layout(location = 1) in vec3 normal_modelspace;
- uniform mat4 model;
- uniform mat4 view;
- uniform mat4 projection;
- out vec3 normal_worldspace;
- void main(){
- //transform normal into worldspace
- normal_worldspace = normalize(vec3(model * vec4(normal_modelspace,0.0)));
- //transform vertex position into screenspace
- vec4 v = vec4(position_modelspace,1);
- vec4 position_worldspace = model * v;
- gl_Position = projection * view * position_worldspace;
- }
- ----------------------------
- #version 330 core
- in vec3 normal_worldspace;
- // Ouput data
- out vec3 color;
- void main()
- {
- float intensity;
- vec3 lightDir;
- vec3 normal;
- lightDir = normalize(vec3(1.0,0.0,1.0));
- normal = normalize(normal_worldspace);
- intensity = max(dot(lightDir,normal),0.0);
- // Output color = red
- color = (vec3(0.5f,0.5f,0.5f) * intensity) + vec3(0.2f,0.2f,0.2f) ;
- }
Add Comment
Please, Sign In to add comment