Another save commit for fog fix
This commit is contained in:
+7
-4
@@ -29,7 +29,7 @@ public abstract class AbstractShaderRenderer {
|
||||
|
||||
protected final ShaderProgram shader;
|
||||
protected final ShaderProgram applyShader;
|
||||
protected GLVertexBuffer boxBuffer;
|
||||
public GLVertexBuffer boxBuffer;
|
||||
protected VertexAttribute va;
|
||||
boolean init = false;
|
||||
|
||||
@@ -46,9 +46,8 @@ public abstract class AbstractShaderRenderer {
|
||||
protected AbstractShaderRenderer(ShaderProgram shader, ShaderProgram applyShader) {
|
||||
this.shader = shader;
|
||||
this.applyShader = applyShader;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (init) return;
|
||||
init = true;
|
||||
@@ -56,7 +55,7 @@ public abstract class AbstractShaderRenderer {
|
||||
va = VertexAttribute.create();
|
||||
va.bind();
|
||||
// Pos
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
setVertexAttributes();
|
||||
va.completeAndCheck(Float.BYTES * 2);
|
||||
|
||||
// Some shader stuff needs to be set a bit later than
|
||||
@@ -65,6 +64,10 @@ public abstract class AbstractShaderRenderer {
|
||||
createBuffer();
|
||||
}
|
||||
|
||||
/** Sets all the vertex attributes */
|
||||
void setVertexAttributes() {
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
};
|
||||
/** Overwrite this to apply uniforms to the shader */
|
||||
void setShaderUniforms(float partialTicks) {};
|
||||
/** Overwrite this to apply uniforms to the apply shader */
|
||||
|
||||
+10
-4
@@ -6,6 +6,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.fog.LodFogConfig;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.Shader;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.glObject.vertexAttribute.VertexAttribute;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
@@ -21,7 +22,7 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
|
||||
|
||||
// public final int modelOffsetUniform;
|
||||
public final int worldYOffsetUniform;
|
||||
// public final int worldYOffsetUniform;
|
||||
|
||||
// Fog Uniforms
|
||||
public final int fogColorUniform;
|
||||
@@ -38,11 +39,11 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
super(new ShaderProgram(
|
||||
() -> Shader.loadFile("shaders/fog/fog.vert", false, new StringBuilder()).toString(),
|
||||
() -> fogConfig.loadAndProcessFragShader("shaders/fog/fog.frag", false).toString(),
|
||||
"fragColor", new String[] { "vPosition", "vPos", "color" }
|
||||
"fragColor", new String[] { "vPos", "vPosition" }
|
||||
));
|
||||
|
||||
// modelOffsetUniform = this.shader.getUniformLocation("modelOffset");
|
||||
worldYOffsetUniform = this.shader.getUniformLocation("worldYOffset");
|
||||
// worldYOffsetUniform = this.shader.tryGetUniformLocation("worldYOffset");
|
||||
// Fog uniforms
|
||||
fogColorUniform = this.shader.getUniformLocation("fogColor");
|
||||
fullFogModeUniform = this.shader.getUniformLocation("fullFogMode");
|
||||
@@ -53,6 +54,11 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
nearFogLengthUniform = this.shader.tryGetUniformLocation("nearFogLength");
|
||||
}
|
||||
|
||||
@Override
|
||||
void setVertexAttributes() {
|
||||
this.va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
this.va.setVertexAttribute(0, 1, VertexAttribute.VertexPointer.addUnsignedShortsPointer(8, false, true)); // 2+2+2+2
|
||||
};
|
||||
|
||||
@Override
|
||||
void setShaderUniforms(float partialTicks) {
|
||||
@@ -62,7 +68,7 @@ public class FogShader extends AbstractShaderRenderer {
|
||||
vanillaDrawDistance += 32; // Give it a 2 chunk boundary for near fog.
|
||||
|
||||
|
||||
this.shader.setUniform(worldYOffsetUniform, (float) MC.getWrappedClientWorld().getMinHeight());
|
||||
// if (worldYOffsetUniform != -1) this.shader.setUniform(worldYOffsetUniform, (float) MC.getWrappedClientWorld().getMinHeight());
|
||||
|
||||
// Fog
|
||||
this.shader.setUniform(fullFogModeUniform, MC_RENDER.isFogStateSpecial() ? 1 : 0);
|
||||
|
||||
+8
-2
@@ -1,6 +1,7 @@
|
||||
package com.seibel.distanthorizons.core.render.renderer.shaders;
|
||||
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
import com.seibel.distanthorizons.core.render.glObject.vertexAttribute.VertexAttribute;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
@@ -16,9 +17,9 @@ public class SSAOShader extends AbstractShaderRenderer {
|
||||
public SSAOShader() {
|
||||
super(
|
||||
new ShaderProgram("shaders/normal.vert", "shaders/ssao/ao.frag",
|
||||
"fragColor", new String[]{"vPos"}),
|
||||
"fragColor", new String[]{"vPosition"}),
|
||||
new ShaderProgram("shaders/normal.vert", "shaders/ssao/apply-frag.frag",
|
||||
"fragColor", new String[]{"vPos"})
|
||||
"fragColor", new String[]{"vPosition"})
|
||||
);
|
||||
|
||||
}
|
||||
@@ -28,6 +29,11 @@ public class SSAOShader extends AbstractShaderRenderer {
|
||||
kernel = genKernel();
|
||||
}
|
||||
|
||||
@Override
|
||||
void setVertexAttributes() {
|
||||
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
void setShaderUniforms(float partialTicks) {
|
||||
Mat4f perspective = Mat4f.perspective(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
in vec3 vertexWorldPos;
|
||||
in float vertexYPos;
|
||||
//in uvec4 vPosition;
|
||||
//in vec2 TexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
@@ -69,20 +70,20 @@ void main() {
|
||||
}
|
||||
|
||||
// Testing
|
||||
// if (fragColor.r != 6969.) { // This line is so that the compiler doesnt delete the previos code
|
||||
//// fragColor = vec4(
|
||||
//// mod(vertexWorldPos.x, 1),
|
||||
//// mod(vertexWorldPos.y, 1),
|
||||
//// mod(vertexWorldPos.z, 1),
|
||||
//// 1.
|
||||
//// );
|
||||
if (fragColor.r != 6969.) { // This line is so that the compiler doesnt delete the previos code
|
||||
fragColor = vec4(
|
||||
mod(vertexWorldPos.x, 1),
|
||||
mod(vertexWorldPos.y, 1),
|
||||
mod(vertexWorldPos.z, 1),
|
||||
1.
|
||||
);
|
||||
// fragColor = vec4(
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(vertexYPos, 1),
|
||||
// mod(vPosition.x, 1),
|
||||
// mod(vPosition.y, 1),
|
||||
// mod(vPosition.z, 1),
|
||||
// 1.
|
||||
// );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
//uniform vec3 modelOffset;
|
||||
uniform float worldYOffset;
|
||||
//uniform float worldYOffset;
|
||||
|
||||
//in uvec4 vPosition;
|
||||
in vec2 vPos;
|
||||
in uvec4 vPosition;
|
||||
out vec3 vertexWorldPos;
|
||||
out float vertexYPos;
|
||||
|
||||
@@ -13,7 +13,10 @@ out float vertexYPos;
|
||||
void main()
|
||||
{
|
||||
// vertexWorldPos = vPosition.xyz + modelOffset;
|
||||
vertexYPos = vPosition.y + worldYOffset;
|
||||
// vertexWorldPos = vPosition.xyz;
|
||||
vertexWorldPos = vec3(0.);
|
||||
vertexYPos = 0.;
|
||||
// vertexYPos = vPosition.y + worldYOffset;
|
||||
|
||||
gl_Position = vec4(vPos, 1.0, 1.0);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#version 150 core
|
||||
|
||||
in vec2 vPos;
|
||||
in vec2 vPosition;
|
||||
out vec2 TexCoord;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vPos, 1.0, 1.0);
|
||||
TexCoord = vPos.xy * 0.5 + 0.5;
|
||||
gl_Position = vec4(vPosition, 1.0, 1.0);
|
||||
TexCoord = vPosition.xy * 0.5 + 0.5;
|
||||
}
|
||||
Reference in New Issue
Block a user