Posted December 10, 20168 yr My mod logic listens for the RenderLivingEvent.Post event so that it can render text above a player's head. Mechanically everything works fine. However, the text will "dim" when it gets into dark areas, like underground. I was wondering if there is a GlStateManager command that will prevent this dimming from happening - I want the text to stay at a normal brightness. Thanks!
December 10, 20168 yr My mod logic listens for the RenderLivingEvent.Post event so that it can render text above a player's head. Mechanically everything works fine. However, the text will "dim" when it gets into dark areas, like underground. I was wondering if there is a GlStateManager command that will prevent this dimming from happening - I want the text to stay at a normal brightness. Thanks! Try GLStateManager.disableLighting(); And if that doesn't work post your rendering code. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 10, 20168 yr Author Tried that already and it didn't work. Of course, I could have put it in the wrong place. Here is my current code for the text drawing routine: private static void drawText(final FontRenderer font, final List<String> input, final float x, final float y, final float z, final float viewerYaw, final float viewerPitch, final boolean isThirdPersonFrontal, final boolean isSneaking) { final int numberOfMessages = input.size(); int maxWidth = MIN_TEXT_WIDTH; for (final String s : input) { int strWidth = font.getStringWidth(s); if (strWidth > maxWidth) maxWidth = strWidth; } // Calculate scale and position final float scaleBase = 0.8F; // 1.6F; final float scale = scaleBase * 0.016666668F; final double top = -(numberOfMessages) * 9 - BUBBLE_MARGIN; final double bottom = BUBBLE_MARGIN; final double left = -(maxWidth / 2.0D + BUBBLE_MARGIN); final double right = maxWidth / 2.0D + BUBBLE_MARGIN; final Tessellator tessellator = Tessellator.getInstance(); final VertexBuffer buffer = tessellator.getBuffer(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-viewerYaw, 0.0F, 1.0F, 0.0F); GlStateManager.rotate((float) (isThirdPersonFrontal ? -1 : 1) * viewerPitch, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-scale, -scale, scale); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.disableTexture2D(); // Draw the background region final float red = B_COLOR.red; final float green = B_COLOR.green; final float blue = B_COLOR.blue; final float alpha = B_COLOR_ALPHA; buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); buffer.pos(left, top, 0.0D).color(red, green, blue, alpha).endVertex(); buffer.pos(left, bottom, 0.0D).color(red, green, blue, alpha).endVertex(); buffer.pos(right, bottom, 0.0D).color(red, green, blue, alpha).endVertex(); buffer.pos(right, top, 0.0D).color(red, green, blue, alpha).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); int lines = numberOfMessages; for (int t = 0; t < numberOfMessages; t++) { final String str = input.get(t); final int offset = -lines * 9; final int margin = -font.getStringWidth(str) / 2; GlStateManager.disableDepth(); font.drawString(str, margin, offset, F_COLOR.rgb()); GlStateManager.enableDepth(); GlStateManager.depthMask(true); font.drawString(str, margin, offset, F_COLOR.rgb()); lines--; } GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); }
December 11, 20168 yr Could you provide a screen shot or tell me what exactly is "dimming"? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 11, 20168 yr I don't fully understand your code, but that's probably because I am new. I do see enableLighting() at the end of your code, though. Does that affect anything? I don't have that much experience with rendering. GL has a number of capabilities that can be enabled or disabled. Before you actually render anything you may need to change several of these. After you are done rendering, you should disable any capabilities you enabled and enable any capabilities you disabled. Doing this prevents strange behaviour when something else is rendered. The call to enableLighting() is present after OP finishes rendering because they called disbleLighting() before they started rendering.
December 11, 20168 yr I don't fully understand your code, but that's probably because I am new. I do see enableLighting() at the end of your code, though. Does that affect anything? I don't have that much experience with rendering. GL has a number of capabilities that can be enabled or disabled. Before you actually render anything you may need to change several of these. After you are done rendering, you should disable any capabilities you enabled and enable any capabilities you disabled. Doing this prevents strange behaviour when something else is rendered. The call to enableLighting() is present after OP finishes rendering because they called disbleLighting() before they started rendering. Does it really matter if he calls GLStateManager.pushMatrix() and GLStateManager.popMatrix() though? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 11, 20168 yr Does it really matter if he calls GLStateManager.pushMatrix() and GLStateManager.popMatrix() though? Yes. GL states aren't affected by push/pop matrix. The translation matrix only handles translation, rotation, and scale. Color, blending, light, culling, ztest, and so on are not covered by push/pop matrix. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 11, 20168 yr Does it really matter if he calls GLStateManager.pushMatrix() and GLStateManager.popMatrix() though? Yes. GL states aren't affected by push/pop matrix. The translation matrix only handles translation, rotation, and scale. Color, blending, light, culling, ztest, and so on are not covered by push/pop matrix. Awe, that is kinda disappointing, it would be so cool if it did, because then I wouldn't have to assume that "all" states are not what I want them to be. But i guess there are reasons. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 11, 20168 yr Author Normally in full light, such as in a cave standing by a torch, the objects I render look fine color wise. If I were to walk away from the torch into the darkness the objects I render become darker because there is less light "hitting" it. What I want to do is tell the render engine not to worry about the lighting and just render my items without the fancy light effects.
December 11, 20168 yr Normally in full light, such as in a cave standing by a torch, the objects I render look fine color wise. If I were to walk away from the torch into the darkness the objects I render become darker because there is less light "hitting" it. What I want to do is tell the render engine not to worry about the lighting and just render my items without the fancy light effects. Try disabling blend. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
December 11, 20168 yr Author Found a way to do it: OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, ...); You can find my updated code here. Not sure what the parameters are doing exactly so I need to do more research. Thanks for the help guys/gals!
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.