diff options
| author | tech kaczynski <tk@techkaczynski.dev> | 2026-09-22 22:38:57 +1000 |
|---|---|---|
| committer | tech kaczynski <tk@techkaczynski.dev> | 2026-09-22 22:38:57 +1000 |
| commit | 08cb8d6a585dd552b69a488d9db1be123f01467a (patch) | |
| tree | 77d50ce30bbc102b08486929ba654b5bef70af43 /res/sdr/mdl_lit.fs | |
initial commit.
Diffstat (limited to 'res/sdr/mdl_lit.fs')
| -rw-r--r-- | res/sdr/mdl_lit.fs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/res/sdr/mdl_lit.fs b/res/sdr/mdl_lit.fs new file mode 100644 index 0000000..f3a51c6 --- /dev/null +++ b/res/sdr/mdl_lit.fs @@ -0,0 +1,69 @@ +#version 330 + +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +uniform vec3 sun_direction; +uniform vec3 sun_colour; +uniform float sun_intensity; + +uniform vec3 moon_direction; +uniform vec3 moon_colour; +uniform float moon_intensity; + +uniform vec3 ambient_colour; +uniform float ambient_intensity; + +in vec2 frag_texcoord; +in vec4 frag_colour; +in vec3 frag_world_normal; + +out vec4 finalColor; + +void +main() +{ + vec3 normal = normalize(frag_world_normal); + + // float sun_diffuse = max( + // dot(normal, sun_direction), + // 0.0 + // ); + + // half lambert + float sun_diffuse = dot(normal, sun_direction) * 0.5 + 0.5; + sun_diffuse *= sun_diffuse; + + float moon_diffuse = max( + dot(normal, moon_direction), + 0.0 + ); + + vec3 ambient_light = + ambient_colour * ambient_intensity; + + vec3 sun_light = + sun_colour * + sun_intensity * + sun_diffuse; + + vec3 moon_light = + moon_colour * + moon_intensity * + moon_diffuse; + + vec3 lighting = + ambient_light + + sun_light + + moon_light; + + vec4 texel = + texture(texture0, frag_texcoord) * + colDiffuse * + frag_colour; + + finalColor = vec4( + texel.rgb * max(lighting, vec3(0.0)), + texel.a + ); +} |
