Bug behoben bei den Texturen

This commit is contained in:
2026-08-10 12:33:10 +02:00
parent 9561966071
commit 294a080a3c
5 changed files with 62 additions and 74 deletions

View File

@@ -9,6 +9,10 @@ uniform sampler2D m_AlphaMap_1;
uniform sampler2D m_AlphaMap_2;
#endif
#ifdef HAS_STEEP
uniform int m_SteepIndex;
#endif
uniform vec3 m_LightDir;
uniform vec3 m_SunColor;
uniform vec3 m_AmbientColor;
@@ -19,6 +23,15 @@ in vec3 vNormal;
out vec4 outColor;
#ifdef HAS_STEEP
// Triplanare Textur-Abfrage aus einem Sampler2DArray-Layer
vec4 triplanarArray(vec2 uvX, vec2 uvY, vec2 uvZ, vec3 bw, int idx) {
return texture(m_DiffuseArray, vec3(uvX, float(idx))) * bw.x
+ texture(m_DiffuseArray, vec3(uvY, float(idx))) * bw.y
+ texture(m_DiffuseArray, vec3(uvZ, float(idx))) * bw.z;
}
#endif
void main() {
// World-space splatmap UV (identisch zur Painting-Logik in TerrainEditorState)
vec2 splatUV = vec2(
@@ -51,6 +64,19 @@ void main() {
}
}
#ifdef HAS_STEEP
// Klippen-Textur: Triplanar auf steilen Flächen (identisch zu Voxel.frag)
vec3 bw = pow(abs(vNormal), vec3(4.0));
bw /= (bw.x + bw.y + bw.z + 0.001);
float steepScale = m_DiffuseScales[m_SteepIndex];
vec2 uvX = vWorldPos.yz / steepScale;
vec2 uvZ = vWorldPos.xy / steepScale;
float flatBlend = smoothstep(0.70, 0.90, vNormal.y);
float steepBlend = 1.0 - flatBlend;
vec4 steepCol = triplanarArray(uvX, vWorldPos.xz / steepScale, uvZ, bw, m_SteepIndex);
col = col * flatBlend + steepCol * steepBlend;
#endif
vec3 N = normalize(vNormal);
vec3 lightDir = normalize(m_LightDir);
float diff = max(dot(N, lightDir), 0.0);