SHARE
TWEET

Untitled

a guest Dec 26th, 2014 191 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 330
  2.  
  3. uniform samplerCube skyboxTex;
  4. uniform mat4 MV;
  5. uniform vec3 cameraPosition;
  6.  
  7. const float radius = 0.5f;
  8. const vec3 lightPosition = vec3(0.0f, 10.0f, 0.0f);
  9.  
  10. const vec3 colorDiffuse = vec3(0.2f, 0.45f, 0.89f);
  11.  
  12. const vec3 colorSpecular = vec3(1.0f);
  13. const float shininess = 10.0f;
  14.  
  15. const float refractIndex = 1.0f/1.3333f;
  16.  
  17. in vec4 fPosition;
  18.  
  19. out vec4 fColor;
  20.  
  21. void main(void)
  22. {
  23.     vec3 N;
  24.     N.xy = gl_PointCoord * 2.0f - 1.0f;
  25.     float r2 = dot(N.xy,N.xy);
  26.     if(r2 > 1.0f) discard;
  27.     N.z = sqrt(1.0f - r2);
  28.     N = normalize(N);
  29.  
  30.     // View-space fragment's position
  31.     vec3 position = fPosition.xyz + N*radius;
  32.  
  33.     // Light direction - from surface to light
  34.     vec3 L = normalize(lightPosition - position);
  35.     // Incident light direction - from light to surface
  36.     vec3 Ilight = -L;
  37.     // Reflect incident light direction around the normal
  38.     vec3 Rlight = reflect(Ilight,N);
  39.     // View direction - from surface to camera
  40.     vec3 V = normalize(cameraPosition - position);
  41.     // Incident view direction - from camera to surface
  42.     vec3 Iview = -V;
  43.     // Reflect incident view direction around the normal
  44.     vec3 Rl_view = -reflect(Iview,N);
  45.     // Refract incident view direction around the normal
  46.     vec3 Rr_view = refract(Iview,N,refractIndex);
  47.  
  48.     float diffuse = max(0.0f, dot(L,N));
  49.     float specular = 0.0f;
  50.     if(diffuse > 0.0f)
  51.         specular = pow(max(0.0f, dot(V,Rlight)),shininess);
  52.  
  53.     fColor = vec4(diffuse*colorDiffuse, 1.0f);
  54.     //fColor = vec4(specular*colorSpecular + diffuse*colorDiffuse, 1.0f);
  55.     //fColor = texture(skyboxTex,Rview);
  56.     //fColor = texture(skyboxTex,Rr_view);
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top