Bug behoben bei den Texturen
This commit is contained in:
@@ -6,6 +6,8 @@ MaterialDef BakedTerrain {
|
||||
Texture2D AlphaMap
|
||||
Texture2D AlphaMap_1
|
||||
Texture2D AlphaMap_2
|
||||
Boolean HasSteep
|
||||
Int SteepIndex
|
||||
Vector3 LightDir : 0.6 -0.8 0.4
|
||||
Vector3 SunColor : 0.68 0.65 0.60
|
||||
Vector3 AmbientColor : 0.08 0.10 0.16
|
||||
@@ -25,6 +27,7 @@ MaterialDef BakedTerrain {
|
||||
Defines {
|
||||
HAS_ALPHA_1 : AlphaMap_1
|
||||
HAS_ALPHA_2 : AlphaMap_2
|
||||
HAS_STEEP : HasSteep
|
||||
DEBUG_NO_LIGHT : DebugNoLight
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user