Jump to content

Render Flicker


delpi

Recommended Posts

I have a custom entity where two of the body parts occupy the same space.  For all purposes, just consider it having 2 heads of the exact same size in exact same place even thought that isn't it.

 

The problem is that when the entity turns or moves, the area that they share flickers.  How do I make it so one of the heads is always on the outside?

 

I've searched, but I'm probably just using the wrong phrases.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I ran into the same problem recently.  I was a bit surprised because I figured that if they exactly aligned that the render order would generally be constant, but someone else suggested roundoff error causes flickering on overlapping parts.

 

One solution is to scale one part just slightly such that it doesn't seem obviously mismatched in size but the render is always properly ordered.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

In my model class, within the render() method.

 

For example, for my elephant I did the following:

            head.render(par7);
            body.render(par7);
            // scale legs slightly to reduce render flicker on overlapping areas
            GL11.glPushMatrix();
            GL11.glScalef(0.99F, 0.00F, 0.99F);
            legRearRight.render(par7);
            legRearLeft.render(par7);
            legFrontRight.render(par7);
            legFrontLeft.render(par7);
            GL11.glPopMatrix();

 

I only scaled in x and z direction because those were the dimensions that caused the overlap.  You could probably make it even tighter with 0.999F or something.

 

Definitely fixed it for me, assuming the flicker you're talking about is the same type.

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

That should fix it.  THANKS.

 

One last question.  Did you have to offset the texture at that point?  Perhaps 0.98 in scale and translate by 0.01?

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

That should fix it.  THANKS.

 

One last question.  Did you have to offset the texture at that point?  Perhaps 0.98 in scale and translate by 0.01?

 

Well, the point is actually to do the scaling so close to 1.0 that it the scaling (and any offset) is pretty much unnoticeable.  But yeah technically you should probably adjust the offset by half the difference between 1.0 and your scale factor.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I just learned something new.  Can't claim I'm anywhere near proficient in GL, but didn't realize this.

 

When I scalef it on the x coord, it centers it instead of shrinking it left or right.  0.99 seems to do it.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.