diff options
author | Jesse Barker <jesse.barker@linaro.org> | 2012-12-07 11:57:44 -0800 |
---|---|---|
committer | Jesse Barker <jesse.barker@linaro.org> | 2012-12-07 11:57:44 -0800 |
commit | b00c4a2ee5648d25402684302122dabfffa318bf (patch) | |
tree | 8dd187298beee12d0939bd26b4810412395017fa /data/shaders/light-refract.frag | |
parent | 8eef3806a2aa39f2018d0bfbc6f34a1f8a5cda7e (diff) | |
download | glmark2-b00c4a2ee5648d25402684302122dabfffa318bf.tar.gz |
SceneRefract: First cut at a new scene that will demonstrate the refraction of
light through a transparent object.
Diffstat (limited to 'data/shaders/light-refract.frag')
-rw-r--r-- | data/shaders/light-refract.frag | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/data/shaders/light-refract.frag b/data/shaders/light-refract.frag new file mode 100644 index 0000000..f7ae395 --- /dev/null +++ b/data/shaders/light-refract.frag @@ -0,0 +1,24 @@ +uniform sampler2D DistanceMap; + +varying vec3 vertex_normal; +varying vec4 vertex_position; + +void main() +{ + const vec4 lightAmbient = vec4(0.1, 0.1, 0.1, 1.0); + const vec4 lightSpecular = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0); + const vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0); + const float matShininess = 100.0; + vec3 eye_direction = normalize(-vertex_position.xyz); + vec3 light_direction = normalize(LightSourcePosition.xyz/LightSourcePosition.w - + vertex_position.xyz/vertex_position.w); + vec3 normalized_normal = normalize(vertex_normal); + vec3 reflection = reflect(-light_direction, normalized_normal); + float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess); + float diffuseTerm = max(0.0, dot(normalized_normal, light_direction)); + vec4 specular = (lightSpecular * matSpecular); + vec4 ambient = (lightAmbient * matAmbient); + vec4 diffuse = (LightColor * MaterialDiffuse); + gl_FragColor = (specular * specularTerm) + ambient + (diffuse * diffuseTerm); +} |