Hackfix for translucency being double applied
This commit is contained in:
@@ -144,9 +144,18 @@ public class ModelTextureBakery {
|
|||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
//glDepthFunc(GL_LESS);
|
//glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
glBlendEquation(GL_FUNC_ADD);//TODO: reset this to the default
|
|
||||||
|
|
||||||
|
//TODO: Find a better solution
|
||||||
|
if (renderLayer == RenderLayer.getTranslucent()) {
|
||||||
|
//Very hacky blend function to retain the effect of the applied alpha since we dont really want to apply alpha
|
||||||
|
// this is because we apply the alpha again when rendering the terrain meaning the alpha is being double applied
|
||||||
|
glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
} else {
|
||||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
|
||||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static org.lwjgl.opengl.ARBMultiDrawIndirect.glMultiDrawElementsIndirect;
|
|||||||
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
||||||
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_SHORT;
|
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_SHORT;
|
||||||
import static org.lwjgl.opengl.GL11.glGetInteger;
|
import static org.lwjgl.opengl.GL11.glGetInteger;
|
||||||
|
import static org.lwjgl.opengl.GL14C.glBlendFuncSeparate;
|
||||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||||
import static org.lwjgl.opengl.GL30C.GL_R8UI;
|
import static org.lwjgl.opengl.GL30C.GL_R8UI;
|
||||||
import static org.lwjgl.opengl.GL30C.GL_RED_INTEGER;
|
import static org.lwjgl.opengl.GL30C.GL_RED_INTEGER;
|
||||||
@@ -172,15 +173,18 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
|||||||
RenderLayer.getTranslucent().startDrawing();
|
RenderLayer.getTranslucent().startDrawing();
|
||||||
glBindVertexArray(this.vao);
|
glBindVertexArray(this.vao);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
RenderSystem.enableBlend();
|
glEnable(GL_BLEND);
|
||||||
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
//TODO: maybe change this so the alpha isnt applied in the same way or something?? since atm the texture bakery uses a very hacky
|
||||||
|
// blend equation to make it avoid double applying translucency
|
||||||
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
int oldActiveTexture = glGetInteger(GL_ACTIVE_TEXTURE);
|
|
||||||
|
|
||||||
glBindSampler(0, this.models.getSamplerId());
|
glBindSampler(0, this.models.getSamplerId());
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
int oldBoundTexture = glGetInteger(GL_TEXTURE_BINDING_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, this.models.getTextureId());
|
glBindTexture(GL_TEXTURE_2D, this.models.getTextureId());
|
||||||
|
|
||||||
|
//RenderSystem.blendFunc(GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE);
|
||||||
this.lodShader.bind();
|
this.lodShader.bind();
|
||||||
|
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
@@ -192,9 +196,7 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
|||||||
|
|
||||||
|
|
||||||
glBindSampler(0, 0);
|
glBindSampler(0, 0);
|
||||||
GL11C.glBindTexture(GL_TEXTURE_2D, oldBoundTexture);
|
glDisable(GL_BLEND);
|
||||||
glActiveTexture(oldActiveTexture);
|
|
||||||
RenderSystem.disableBlend();
|
|
||||||
|
|
||||||
RenderLayer.getTranslucent().endDrawing();
|
RenderLayer.getTranslucent().endDrawing();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user