Commit vor Voxel Update für die Klippen
This commit is contained in:
54
blight-assets/src/main/resources/Shaders/Voxel.frag
Normal file
54
blight-assets/src/main/resources/Shaders/Voxel.frag
Normal file
@@ -0,0 +1,54 @@
|
||||
uniform sampler2D m_Tex0;
|
||||
uniform sampler2D m_Tex1;
|
||||
uniform sampler2D m_Tex2;
|
||||
uniform sampler2D m_Tex3;
|
||||
uniform float m_TexScale;
|
||||
|
||||
in vec3 vWorldPos;
|
||||
in vec3 vNormal;
|
||||
in vec4 vMatWeights;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec3 blendWeights = abs(vNormal);
|
||||
blendWeights = max(blendWeights - 0.2, 0.0);
|
||||
blendWeights /= (blendWeights.x + blendWeights.y + blendWeights.z + 0.001);
|
||||
|
||||
vec2 uvX = vWorldPos.yz / m_TexScale;
|
||||
vec2 uvY = vWorldPos.xz / m_TexScale;
|
||||
vec2 uvZ = vWorldPos.xy / m_TexScale;
|
||||
|
||||
vec4 col = vec4(0.0);
|
||||
|
||||
float w0 = vMatWeights.r;
|
||||
if (w0 > 0.001) {
|
||||
col += w0 * (texture(m_Tex0, uvX) * blendWeights.x
|
||||
+ texture(m_Tex0, uvY) * blendWeights.y
|
||||
+ texture(m_Tex0, uvZ) * blendWeights.z);
|
||||
}
|
||||
float w1 = vMatWeights.g;
|
||||
if (w1 > 0.001) {
|
||||
col += w1 * (texture(m_Tex1, uvX) * blendWeights.x
|
||||
+ texture(m_Tex1, uvY) * blendWeights.y
|
||||
+ texture(m_Tex1, uvZ) * blendWeights.z);
|
||||
}
|
||||
float w2 = vMatWeights.b;
|
||||
if (w2 > 0.001) {
|
||||
col += w2 * (texture(m_Tex2, uvX) * blendWeights.x
|
||||
+ texture(m_Tex2, uvY) * blendWeights.y
|
||||
+ texture(m_Tex2, uvZ) * blendWeights.z);
|
||||
}
|
||||
float w3 = vMatWeights.a;
|
||||
if (w3 > 0.001) {
|
||||
col += w3 * (texture(m_Tex3, uvX) * blendWeights.x
|
||||
+ texture(m_Tex3, uvY) * blendWeights.y
|
||||
+ texture(m_Tex3, uvZ) * blendWeights.z);
|
||||
}
|
||||
|
||||
vec3 lightDir = normalize(vec3(0.5, 1.0, 0.3));
|
||||
float diff = max(dot(vNormal, lightDir), 0.0) * 0.7 + 0.3;
|
||||
|
||||
outColor = vec4(col.rgb * diff, col.a);
|
||||
if (outColor.a < 0.1) discard;
|
||||
}
|
||||
Reference in New Issue
Block a user