Commit vor großem Terrain refactoring

This commit is contained in:
2026-06-08 08:42:45 +02:00
parent 7faed35287
commit 1297869dfa
119 changed files with 9784 additions and 1614 deletions

View File

@@ -0,0 +1,34 @@
uniform vec4 g_AmbientLightColor;
uniform vec3 m_SunDir; // Richtung von der Fläche zur Sonne (world-space, normiert)
uniform vec4 m_SunColor; // Sonnenfarbe RGB
in vec4 varColor;
in vec3 varNormal;
out vec4 outFragColor;
void main() {
// Normale für Rück- und Vorderseite korrekt ausrichten
vec3 n = normalize(varNormal);
if (!gl_FrontFacing) n = -n;
vec3 L = normalize(m_SunDir);
// Diffuses Licht
float nDotL = max(dot(n, L), 0.0);
// Subsurface-Scatter-Approximation: etwas Licht scheint durch den Halm
float sss = max(dot(-n, L), 0.0) * 0.25;
float light = nDotL + sss;
vec3 ambient = g_AmbientLightColor.rgb * varColor.rgb;
vec3 diffuse = m_SunColor.rgb * varColor.rgb * light;
// Farbe nicht über die Vertex-Color-Helligkeit hinaus aufhellen
vec3 result = ambient + diffuse;
result = min(result, varColor.rgb * 1.5);
outFragColor = vec4(result, 1.0);
}