Silly511 Posted October 19, 2017 Share Posted October 19, 2017 (edited) I'm rendering some things in RenderWorldLastEvent and would like to have fog applied to them. However when I enable fog, it originates from vertex position instead of player position. Here's my code: Tessellator tess = Tessellator.getInstance(); BufferBuilder buffer = tess.getBuffer(); GlStateManager.pushMatrix(); RenderHelper.translateToZero(); GlStateManager.disableTexture2D(); GlStateManager.color(1, 0, 0); GlStateManager.disableCull(); GlStateManager.enableFog(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); buffer.pos(0, 100, 0).endVertex(); buffer.pos(-1.1, 100, 0).endVertex(); buffer.pos(-100, 100, 0).endVertex(); buffer.pos(-101.1, 100, 0).endVertex(); tess.draw(); GlStateManager.disableFog(); GlStateManager.enableCull(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); And this is the translateToZero() method: public static void translateToZero() { Entity entity = mc.getRenderViewEntity(); float partialTicks = mc.getRenderPartialTicks(); GlStateManager.translate( -(entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks), -(entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks), -(entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks) ); } Do I need to draw my quads in a different way? I've never done anything with OpenGL fog. Edited October 19, 2017 by Silly511 Quote Link to comment Share on other sites More sharing options...
Silly511 Posted October 20, 2017 Author Share Posted October 20, 2017 Bump. Quote Link to comment Share on other sites More sharing options...
Silly511 Posted October 21, 2017 Author Share Posted October 21, 2017 Bump again. Quote Link to comment Share on other sites More sharing options...
jabelar Posted October 22, 2017 Share Posted October 22, 2017 You might want to contact TheGreyGhost. He does a fair bit with GL. Otherwise, you need to debug the old fashioned way. You are already right to be suspicious of the translate to zero method. So maybe print out the values and get a sense of what is happening. I expect it is something wrong with the math that will become obvious. For example one thing may be that by the time the render happens the current position and the last tick position may be equal to each other (since at some point in the tick the last tick position must copy the current position and the current position will get updated later). That's my guess. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.