diff options
author | makamys <makamys@outlook.com> | 2022-06-20 22:05:05 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-20 22:05:05 +0200 |
commit | 413bee34e68e977a779a95a0c2e89d60c254d261 (patch) | |
tree | 415796ef6b57519195d0a952f89d884df78c928d /src | |
parent | 42b814f0470317661a23aa1403041cad27ec880f (diff) | |
download | Neodymium-413bee34e68e977a779a95a0c2e89d60c254d261.tar.gz Neodymium-413bee34e68e977a779a95a0c2e89d60c254d261.tar.bz2 Neodymium-413bee34e68e977a779a95a0c2e89d60c254d261.zip |
Fix lava rendering
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 16 | ||||
-rw-r--r-- | src/main/resources/shaders/chunk.frag | 11 | ||||
-rw-r--r-- | src/main/resources/shaders/chunk.vert | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index 3759c65..ff1cb40 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -134,10 +134,18 @@ public class MeshQuad { out.writeInt(c); - out.writeByte(us[vi] == us[provokingI] ? 0 : (byte)quadCountByUVDirection(false)); - out.writeByte(vs[vi] == vs[provokingI] ? 0 : (byte)quadCountByUVDirection(true)); - out.writeByte(us[vi] == us[provokingI] ? (byte)0 : 1); - out.writeByte(vs[vi] == vs[provokingI] ? (byte)0 : 1); + if((quadCountByUVDirection(false) == 1 && quadCountByUVDirection(true) == 1)) { + // let the fragment shader know this is not a megaquad + out.writeByte((byte)255); + out.writeByte((byte)255); + out.writeByte((byte)255); + out.writeByte((byte)255); + } else { + out.writeByte(us[vi] == us[provokingI] ? 0 : (byte)quadCountByUVDirection(false)); + out.writeByte(vs[vi] == vs[provokingI] ? 0 : (byte)quadCountByUVDirection(true)); + out.writeByte(us[vi] == us[provokingI] ? (byte)0 : 1); + out.writeByte(vs[vi] == vs[provokingI] ? (byte)0 : 1); + } assert out.position() % getStride() == 0; diff --git a/src/main/resources/shaders/chunk.frag b/src/main/resources/shaders/chunk.frag index b19f152..24cc97e 100644 --- a/src/main/resources/shaders/chunk.frag +++ b/src/main/resources/shaders/chunk.frag @@ -17,10 +17,13 @@ uniform sampler2D lightTex; void main() { - float wrappedU = mod(MQPos.x, 1.0); - float wrappedV = mod(MQPos.y, 1.0); - - vec2 goodTexCoord = ProvokingTexCoord.xy + (((TexCoord.xy - ProvokingTexCoord.xy) / MQPos.zw) * vec2(wrappedU, wrappedV)); + vec2 goodTexCoord = TexCoord; + if(MQPos.x <= 254){ + float wrappedU = mod(MQPos.x, 1.0); + float wrappedV = mod(MQPos.y, 1.0); + + goodTexCoord = ProvokingTexCoord.xy + (((TexCoord.xy - ProvokingTexCoord.xy) / MQPos.zw) * vec2(wrappedU, wrappedV)); + } vec4 texColor = texture(atlas, goodTexCoord); diff --git a/src/main/resources/shaders/chunk.vert b/src/main/resources/shaders/chunk.vert index 9fee06c..eb43942 100644 --- a/src/main/resources/shaders/chunk.vert +++ b/src/main/resources/shaders/chunk.vert @@ -3,7 +3,7 @@ layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; layout (location = 2) in vec2 aBTexCoord; layout (location = 3) in vec4 aColor; -layout (location = 4) in vec4 aMQPos; +layout (location = 4) in vec4 aMQPos; // if the first coordinate is 255, it means: disable megaquad processing for this quad uniform mat4 modelView; uniform mat4 proj; @@ -22,7 +22,7 @@ out vec4 Viewport; out mat4 ProjInv; out vec4 FogColor; out vec2 FogStartEnd; -out float FogFactor; +out float FogFactor; // -1 means: disable fog flat out vec2 ProvokingTexCoord; void main() |