Add basic lighting

This commit is contained in:
crumblingstatue 2023-04-06 18:40:34 +02:00
parent 45acd4c1ac
commit d1df7cd472
4 changed files with 58 additions and 17 deletions

16
shaders/lighting.glsl Normal file
View file

@ -0,0 +1,16 @@
uniform sampler2D texture;
uniform float ambient;
uniform bool has_texture;
void main()
{
// lookup the pixel in the texture
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
// multiply it by the color
vec4 col = gl_Color;
if (has_texture) {
col = gl_Color * pixel;
}
gl_FragColor = vec4(col.x * ambient, col.y * ambient, col.z * ambient, col.w);
}