Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. in vec3 vNormal;
  2. in vec2 vTexCoords;
  3. in vec4 vColour;
  4. in vec3 vPosition;
  5. in float depth_space;
  6.  
  7. struct Light
  8. {
  9.     vec4 position;
  10.     vec4 ambient;
  11.     vec4 diffuse;
  12.     vec4 specular;
  13. };
  14.  
  15. void main() {
  16.     vec4 light_colour = vec4(0.0, 0.0, 0.0, 1.0);
  17.    
  18.     Light lightPoint = Light(
  19.             vec4(256.0, 256.0, 5.0, 1.0),
  20.             vec4(0.5,   0.5,   0.5, 1.0),
  21.             vec4(1.0,   1.0,   1.0, 1.0),
  22.             vec4(1.0,   1.0,   1.0, 1.0));
  23.            
  24.     vec3 N = normalize(vNormal);
  25.     vec3 E = normalize(-vPosition);
  26.     vec3 L = normalize(lightPoint.position.xyz - vPosition);
  27.     vec3 R = reflect(-L, N);
  28.     float lambertTerm = dot(N,L);
  29.    
  30.    
  31.     // This errors
  32.     //vec4 diffuseTerm = lightPoint.diffuse * vec4(lambertTerm, lambertTerm, lambertTerm, 1.0);
  33.    
  34.     // This DOES NOT error
  35.     vec4 diffuseTerm = lightPoint.diffuse;
  36.    
  37.    
  38.     light_colour += diffuseTerm;   
  39.     //float specular = pow( max(dot(R, E), 0.0), 1 );
  40.     //light_colour += lightPoint.specular * specular;
  41.    
  42.     vec4 textureSample = texture(sampler, vTexCoords);
  43.     if(textureSample.a <= 0){
  44.         discard;
  45.     }
  46.    
  47.     out_Colour = textureSample * vColour * light_colour;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement