Kaydet (Commit) 6bc132f8 authored tarafından Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot Kaydeden (comit) Tomaž Vajngerl

slideshow: Add back lighting in the SimpleTransition shaders

Change-Id: Iec854a8369a7a9f845f261233e46aea8097db109
üst b8eff3af
......@@ -30,10 +30,14 @@
uniform sampler2D slideTexture;
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main() {
// TODO: handle lighting.
gl_FragColor = texture2D(slideTexture, v_texturePosition);
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture2D(slideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
gl_FragColor = mix(black, fragment, light);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -29,11 +29,13 @@
#version 120
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main( void )
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
v_normal = normalize(gl_NormalMatrix * gl_Normal);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -31,9 +31,15 @@
uniform sampler2D slideTexture;
varying float v_isShadow;
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main() {
vec3 lightVector = vec3(0.0, 0.0, 1.0);
float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture2D(slideTexture, v_texturePosition);
vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
fragment = mix(black, fragment, light);
if (v_isShadow > 0.5) {
if (v_texturePosition.y > 1.0 - 0.3)
gl_FragColor = mix(fragment, vec4(0.0, 0.0, 0.0, 0.0), (1.0 - v_texturePosition.y) / 0.3);
......
......@@ -28,13 +28,15 @@
#version 130
varying float v_isShadow;
varying vec2 v_texturePosition;
varying vec3 v_normal;
varying float v_isShadow;
void main( void )
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
v_normal = normalize(gl_NormalMatrix * gl_Normal);
v_isShadow = float(gl_VertexID >= 6);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment