Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Problem with Fullbright Quads
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Draco18s

[1.7.10] Problem with Fullbright Quads

By Draco18s, August 13, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted August 13, 2015

I'm trying to draw some world-information as an overlay (so 3D quads, not 2D HUD things) and I'm having two problems:

 

1) I can't get the quads to be full-bright.  They flicker between various lighting values as the camera moves. Pic

2) The block outline's outline color changes. Pic

 

@SubscribeEvent
public void renderEvent(DrawBlockHighlightEvent event) {
	...
		GL11.glPushMatrix();
		GL11.glTranslated(-event.player.posX, -event.player.posY, -event.player.posZ);
		GL11.glDisable(GL11.GL_LIGHTING);
		drawLine(thisBlock, points[i]);
	...
}

private void drawLine(Vec3 blockA, Vec3 blockB) {
	Tessellator tess = Tessellator.instance;
	tess.setBrightness(15728880);
	tess.startDrawing(7);
	int d = Math.round((float)blockA.distanceTo(blockB)+0.2f);

	tess.setColorOpaque_F(1F, 0F, 0F);

	float ox = (blockA.xCoord - blockB.xCoord == 0?-1f/16f:0);
	float oz = (blockA.zCoord - blockB.zCoord == 0?1f/16f:0);

	if(blockA.xCoord - blockB.xCoord > 0 || blockA.zCoord - blockB.zCoord > 0) {
		tess.addVertex(blockA.xCoord + 0.5 + ox, blockA.yCoord - 0.01, blockA.zCoord + 0.5 + oz);
		tess.addVertex(blockB.xCoord + 0.5 + ox, blockB.yCoord + 0.99, blockB.zCoord + 0.5 + oz);
		tess.addVertex(blockB.xCoord + 0.5 - ox, blockB.yCoord + 0.99, blockB.zCoord + 0.5 - oz);
		tess.addVertex(blockA.xCoord + 0.5 - ox, blockA.yCoord - 0.01, blockA.zCoord + 0.5 - oz);
	}
	else {
		tess.addVertex(blockA.xCoord + 0.5 - ox, blockA.yCoord - 0.01, blockA.zCoord + 0.5 - oz);
		tess.addVertex(blockB.xCoord + 0.5 - ox, blockB.yCoord + 0.99, blockB.zCoord + 0.5 - oz);
		tess.addVertex(blockB.xCoord + 0.5 + ox, blockB.yCoord + 0.99, blockB.zCoord + 0.5 + oz);
		tess.addVertex(blockA.xCoord + 0.5 + ox, blockA.yCoord - 0.01, blockA.zCoord + 0.5 + oz);
	}

	tess.draw();
}

 

What've I missed?

  • Quote

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.

Share this post


Link to post
Share on other sites

larsgerrits    514

larsgerrits

larsgerrits    514

  • Reality Controller
  • larsgerrits
  • Members
  • 514
  • 3462 posts
Posted August 13, 2015

1) Where do  you pop your matrix?

2) Maybe using

glPushAttrib

and

glPopAttrib

will help.

  • Quote

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted August 13, 2015

1) Where do  you pop your matrix?

2) Maybe using

glPushAttrib

and

glPopAttrib

will help.

 

1) I trimmed it (there's about 12 lines I removed, checking for various things).  I know about push/pop.  In retrospect I should have left that in.

2)

GL11.glPushAttrib(GL11.GL_ENABLE_BIT)

fixed the block outline color though, thanks!

 

But I still have an issue with the lighting on the quads being incorrect.

  • Quote

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.

Share this post


Link to post
Share on other sites

SanAndreasP    402

SanAndreasP

SanAndreasP    402

  • World Shaper
  • SanAndreasP
  • Forge Modder
  • 402
  • 1689 posts
Posted August 13, 2015

1) Where do  you pop your matrix?

2) Maybe using

glPushAttrib

and

glPopAttrib

will help.

 

1) I trimmed it (there's about 12 lines I removed, checking for various things).  I know about push/pop.  In retrospect I should have left that in.

2)

GL11.glPushAttrib(GL11.GL_ENABLE_BIT)

fixed the block outline color though, thanks!

 

But I still have an issue with the lighting on the quads being incorrect.

 

For the light I'd suggest using

OpenGlHelper.setLightmapTextureCoords()

:

// save the previous lighting brightness
            float prevBrightX = OpenGlHelper.lastBrightnessX;
            float prevBrightY = OpenGlHelper.lastBrightnessY;
// declare new brightness (0xF0 is the max. possible)
            int bright = 0xF0;
            int brightX = bright % 65536;
            int brightY = bright / 65536;
// set new brightness
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX / 1.0F, brightY / 1.0F);

// do rendering here


// reset original brightness, so it doesn't mess up anything post-rendered
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevBrightX, prevBrightY);

  • Quote

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted August 13, 2015

Nope, didn't help. :\

 

I'm using the Tessellator for drawing, btw.  And I've already got

tess.setBrightness(15728880)

, but it hasn't made a difference either.

  • Quote

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.

Share this post


Link to post
Share on other sites

TheGreyGhost    819

TheGreyGhost

TheGreyGhost    819

  • Reality Controller
  • TheGreyGhost
  • Members
  • 819
  • 3280 posts
Posted August 14, 2015

Hi Draco

 

You could try calling             

GL11.glColor4f(colour.R, colour.G, colour.B, colour.A);

instead of

tess.setColorOpaque_F(1F, 0F, 0F);

 

That fixed a similar problem I had once before.

 

-TGG

 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted August 14, 2015

You could try calling             

GL11.glColor4f(colour.R, colour.G, colour.B, colour.A);

instead of

tess.setColorOpaque_F(1F, 0F, 0F);

 

Calling tess.setColor...no good

Calling tess.setColor and GL11.glColor...no good

Calling GL11.glColor...no good

 

:\

  • Quote

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.

Share this post


Link to post
Share on other sites

TheGreyGhost    819

TheGreyGhost

TheGreyGhost    819

  • Reality Controller
  • TheGreyGhost
  • Members
  • 819
  • 3280 posts
Posted August 14, 2015

Ah... your code triggers a ghost of a memory... let me check...

 

Try this:

		Tessellator tess = Tessellator.instance;
	tess.startDrawing(7);                                        //swap order
                tess.setBrightness(15728880);

    public void startDrawing(int p_78371_1_)
    {
        if (this.isDrawing)
        {
            throw new IllegalStateException("Already tesselating!");
        }
        else
        {
            this.isDrawing = true;
            this.reset();
            this.drawMode = p_78371_1_;
            this.hasNormals = false;
            this.hasColor = false;
            this.hasTexture = false;
            this.hasBrightness = false;
            this.isColorDisabled = false;
        }
    }

-TGG

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted August 14, 2015

Nope.  And I managed to dredge up an older post of my own that gave me what I needed, albeit in decimal format.

 

glDisable(GL_TEXTURE_2D);

  • Quote

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • kiou.23
      Block Rotate

      By kiou.23 · Posted 11 minutes ago

      That's usually the case, always try to understand the code before copy and pasting, or else you'll get a lot of headaches later in the code's life
    • Varzac
      Forge jar file not opening

      By Varzac · Posted 37 minutes ago

      I ran Jarfix and then tried installing again with the same results. Nothing happening I even tried using winrar, but as you said nothing happened
    • BeardlessBrady
      [1.16.4] Null when OpenGUI

      By BeardlessBrady · Posted 42 minutes ago

      Ah.. Thats what I get for stopping half way through and not double checking, thanks!
    • poopoodice
      [1.16.4] Null when OpenGUI

      By poopoodice · Posted 57 minutes ago

      https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingTile.java#L68 This should not be null.
    • -MCS_Gaming-
      Matchmaking System?

      By -MCS_Gaming- · Posted 59 minutes ago

      I'm making an fps style mod and want to implement a matchmaking system, but I have absolutely no idea where to begin. Would anyone be able to give me some pointers as to how I would go about doing this?
  • Topics

    • ehbean
      10
      Block Rotate

      By ehbean
      Started 7 hours ago

    • Varzac
      3
      Forge jar file not opening

      By Varzac
      Started 13 hours ago

    • BeardlessBrady
      2
      [1.16.4] Null when OpenGUI

      By BeardlessBrady
      Started 1 hour ago

    • -MCS_Gaming-
      0
      Matchmaking System?

      By -MCS_Gaming-
      Started 59 minutes ago

    • Nyko
      1
      [1.16.5] Beacon Overwrite (Screen Error)

      By Nyko
      Started 15 hours ago

  • Who's Online (See full list)

    • The_Deadly_Taco
    • brok4d
    • kiou.23
    • JackRaidenPH
    • NullDev
    • Jeldrik
    • ehbean
    • -MCS_Gaming-
    • Top_DawgsPM
    • BeardlessBrady
    • Twu
    • knees
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Problem with Fullbright Quads
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community