cpu projection inverse

This commit is contained in:
NULL511
2023-08-17 12:08:45 -04:00
parent 4563e4872e
commit be1d13e6ad
2 changed files with 4 additions and 4 deletions
@@ -46,9 +46,9 @@ public class SSAOShader extends AbstractShaderRenderer
MC_RENDER.getTargetFrameBufferViewportWidth() / (float) MC_RENDER.getTargetFrameBufferViewportHeight(),
RenderUtil.getNearClipPlaneDistanceInBlocks(partialTicks),
(float) ((RenderUtil.getFarClipPlaneDistanceInBlocks() + LodUtil.REGION_WIDTH) * Math.sqrt(2)));
this.shader.setUniform(this.shader.getUniformLocation("gProj"), perspective);
this.shader.setUniform(this.shader.getUniformLocation("gProjInv"), perspective.invert());
this.shader.setUniform(this.shader.getUniformLocation("gSampleRad"), 3.0f);
this.shader.setUniform(this.shader.getUniformLocation("gFactor"), 0.8f);
this.shader.setUniform(this.shader.getUniformLocation("gPower"), 1.0f);
+2 -2
View File
@@ -9,6 +9,7 @@ uniform float gSampleRad;
uniform float gFactor;
uniform float gPower;
uniform mat4 gProj;
uniform mat4 gProjInv;
const int MAX_KERNEL_SIZE = 32;
const float INV_MAX_KERNEL_SIZE_F = 1.0 / float(MAX_KERNEL_SIZE);
@@ -20,8 +21,7 @@ vec3 calcViewPosition(vec2 coords) {
vec4 ndc = vec4(coords.xy, fragmentDepth, 1.0);
ndc.xyz = ndc.xyz * 2.0 - 1.0;
// TODO: This inverse() call should be moved CPU side
vec4 vs_pos = inverse(gProj) * ndc;
vec4 vs_pos = gProjInv * ndc;
return vs_pos.xyz / vs_pos.w;
}