diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /apps/openmb/resources/shaders/textured.frag | |
Diffstat (limited to 'apps/openmb/resources/shaders/textured.frag')
| -rw-r--r-- | apps/openmb/resources/shaders/textured.frag | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/openmb/resources/shaders/textured.frag b/apps/openmb/resources/shaders/textured.frag new file mode 100644 index 0000000..ea5e207 --- /dev/null +++ b/apps/openmb/resources/shaders/textured.frag @@ -0,0 +1,45 @@ +#version 330 core + +in vec2 vUV; +out vec4 FragColor; + +uniform sampler2D albedo; +uniform sampler2D normalMap; +uniform int normalEnabled; +uniform float normalStrength; +uniform vec3 tint; +uniform int radialEnabled; +uniform float radialInner; +uniform float radialOuter; + +void main() +{ + vec4 tex = texture(albedo, vUV); + vec3 color = tex.rgb * tint; + float alpha = tex.a; + vec3 finalNormal = vec3(0.0, 0.0, 1.0); + if (normalEnabled == 1) + { + vec3 n = texture(normalMap, vUV).rgb; + n = n * 2.0 - 1.0; + finalNormal = normalize(vec3(n.x * normalStrength, n.y * normalStrength, 1.0)); + } + if (radialEnabled == 1) + { + + float dist = distance(vUV, vec2(0.5, 0.5)); + + float mask = 1.0 - smoothstep(radialInner, radialOuter, dist); + alpha *= mask; + } + + if (normalEnabled == 1) + { + vec3 lightDir = normalize(vec3(0.3, 1.0, 0.5)); + float l = max(dot(normalize(finalNormal), lightDir), 0.0); + + color *= (0.4 + 0.6 * l); + } + + FragColor = vec4(color, alpha); +} |