cpu projection inverse fog
This commit is contained in:
+3
-3
@@ -49,7 +49,7 @@ public class FogShader extends AbstractShaderRenderer
|
||||
// because disabling fog can cause the GLSL to optimize out most (if not all) uniforms
|
||||
|
||||
|
||||
this.gModelViewProjectionUniform = this.shader.tryGetUniformLocation("gMvmProj");
|
||||
this.gModelViewProjectionUniform = this.shader.tryGetUniformLocation("gMvmProjInv");
|
||||
this.gDepthMapUniform = this.shader.tryGetUniformLocation("gDepthMap");
|
||||
|
||||
// Fog uniforms
|
||||
@@ -115,13 +115,13 @@ public class FogShader extends AbstractShaderRenderer
|
||||
|
||||
return fogColor;
|
||||
}
|
||||
|
||||
private Color getSpecialFogColor(float partialTicks) { return MC_RENDER.getSpecialFogColor(partialTicks); }
|
||||
|
||||
public void setModelViewProjectionMatrix(Mat4f combinedModelViewProjectionMatrix)
|
||||
{
|
||||
this.shader.bind();
|
||||
this.shader.setUniform(this.gModelViewProjectionUniform, combinedModelViewProjectionMatrix);
|
||||
this.shader.setUniform(this.gModelViewProjectionUniform, combinedModelViewProjectionMatrix.invert());
|
||||
this.shader.unbind();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ out vec4 fragColor;
|
||||
|
||||
uniform sampler2D gDepthMap;
|
||||
// model view matrix and projection matrix
|
||||
uniform mat4 gMvmProj;
|
||||
uniform mat4 gMvmProjInv;
|
||||
|
||||
uniform float fogScale;
|
||||
uniform float fogVerticalScale;
|
||||
@@ -63,7 +63,7 @@ vec3 calcViewPosition(float fragmentDepth)
|
||||
ndc.xyz = ndc.xyz * 2.0 - 1.0;
|
||||
|
||||
// TODO: This inverse() should be moved CPU side
|
||||
vec4 eyeCoord = inverse(gMvmProj) * ndc;
|
||||
vec4 eyeCoord = gMvmProjInv * ndc;
|
||||
return eyeCoord.xyz / eyeCoord.w;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user