mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 21:56:36 +00:00
23 lines
663 B
GLSL
23 lines
663 B
GLSL
uniform sampler2D tDiffuse;
|
|
uniform sampler2D tPosition;
|
|
uniform sampler2D tNormals;
|
|
uniform vec3 cameraPosition;
|
|
|
|
void main( void )
|
|
{
|
|
vec4 image = texture2D( tDiffuse, gl_TexCoord[0].xy );
|
|
vec4 position = texture2D( tPosition, gl_TexCoord[0].xy );
|
|
vec4 normal = texture2D( tNormals, gl_TexCoord[0].xy );
|
|
|
|
vec3 light = vec3(50,100,50);
|
|
vec3 lightDir = light - position.xyz ;
|
|
|
|
normal = normalize(normal);
|
|
lightDir = normalize(lightDir);
|
|
|
|
vec3 eyeDir = normalize(cameraPosition-position.xyz);
|
|
vec3 vHalfVector = normalize(lightDir.xyz+eyeDir);
|
|
|
|
gl_FragColor = max(dot(normal,lightDir),0) * image + pow(max(dot(normal,vHalfVector),0.0), 100) * 1.5;
|
|
}
|