SHARE
TWEET
Untitled
a guest
Dec 26th, 2014
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #version 330
- uniform samplerCube skyboxTex;
- uniform mat4 MV;
- uniform vec3 cameraPosition;
- const float radius = 0.5f;
- const vec3 lightPosition = vec3(0.0f, 10.0f, 0.0f);
- const vec3 colorDiffuse = vec3(0.2f, 0.45f, 0.89f);
- const vec3 colorSpecular = vec3(1.0f);
- const float shininess = 10.0f;
- const float refractIndex = 1.0f/1.3333f;
- in vec4 fPosition;
- out vec4 fColor;
- void main(void)
- {
- vec3 N;
- N.xy = gl_PointCoord * 2.0f - 1.0f;
- float r2 = dot(N.xy,N.xy);
- if(r2 > 1.0f) discard;
- N.z = sqrt(1.0f - r2);
- N = normalize(N);
- // View-space fragment's position
- vec3 position = fPosition.xyz + N*radius;
- // Light direction - from surface to light
- vec3 L = normalize(lightPosition - position);
- // Incident light direction - from light to surface
- vec3 Ilight = -L;
- // Reflect incident light direction around the normal
- vec3 Rlight = reflect(Ilight,N);
- // View direction - from surface to camera
- vec3 V = normalize(cameraPosition - position);
- // Incident view direction - from camera to surface
- vec3 Iview = -V;
- // Reflect incident view direction around the normal
- vec3 Rl_view = -reflect(Iview,N);
- // Refract incident view direction around the normal
- vec3 Rr_view = refract(Iview,N,refractIndex);
- float diffuse = max(0.0f, dot(L,N));
- float specular = 0.0f;
- if(diffuse > 0.0f)
- specular = pow(max(0.0f, dot(V,Rlight)),shininess);
- fColor = vec4(diffuse*colorDiffuse, 1.0f);
- //fColor = vec4(specular*colorSpecular + diffuse*colorDiffuse, 1.0f);
- //fColor = texture(skyboxTex,Rview);
- //fColor = texture(skyboxTex,Rr_view);
- }
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.

