Commit vor großem Terrain refactoring
This commit is contained in:
34
blight-assets/src/main/resources/Shaders/GrassVertex.frag
Normal file
34
blight-assets/src/main/resources/Shaders/GrassVertex.frag
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user