From b47b2e022bfa74cd94d3296aae6bd34ca4afff02 Mon Sep 17 00:00:00 2001 From: tech kaczynski Date: Mon, 2 Nov 2026 03:23:17 +1000 Subject: new shaders for foliage, new material settings, added lots of assets. --- res/sdr/mdl_two_sided_cutoff.fs | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 res/sdr/mdl_two_sided_cutoff.fs (limited to 'res/sdr/mdl_two_sided_cutoff.fs') diff --git a/res/sdr/mdl_two_sided_cutoff.fs b/res/sdr/mdl_two_sided_cutoff.fs new file mode 100644 index 0000000..c4ac07e --- /dev/null +++ b/res/sdr/mdl_two_sided_cutoff.fs @@ -0,0 +1,51 @@ +#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_normal; + +out vec4 finalColor; + +void main() { + vec4 texel = texture(texture0, frag_texcoord) * frag_colour; + + if (texel.a < 0.5) { + discard; + } + + texel.rgb += colDiffuse.rgb; + + vec3 normal = normalize(frag_normal); + + if (!gl_FrontFacing) { + normal = -normal; + } + + float sun_diffuse = max(dot(normal, sun_direction), 0.0); + 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 = max( + ambient_light + sun_light + moon_light, + vec3(0.0) + ); + + finalColor = vec4(texel.rgb * lighting, 1.0); +} -- cgit v1.2.3