Jump to content

[1.11.2] [Solved] Overlay causing z-fighting when in another chunk


Silly511

Recommended Posts

I have a block model that renders an overlay onto the block beside it. The overlay functions perfectly when both block blocks are in the same chunk, but when one of the blocks is in another chunk as the first one then the overlay and the block start to z-fight. Here's an image of what I'm talking about:

X3mRTpi.png

The black block renders the overlay onto the cobblestone block to the left of it. As you can see when both blocks are in the same chunk they're fine, but when they're in different chunks the cobblestone z-fights the overlay. I think the reason this happens is because each chunk is drawn separately, and two quads in the same draw won't z-fight. But when a quad from one draw is in the same position as a quad from another draw then they z-fight. Is this theory correct? And if it is, is there a way to solve this?

Edited by Silly511
Link to comment
Share on other sites

That's because each chunk is baked down to a single 3D object and rendered.  The z-fighting doesn't occur because the overlay and the cobblestone are in the same mesh and it gets simplified to remove unneeded faces.  But when you render across a chunk boundary, both faces exist in the same space and OpenGL has to render both of them, but can't z-sort them.

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.

Link to comment
Share on other sites

47 minutes ago, Draco18s said:

That's because each chunk is baked down to a single 3D object and rendered.  The z-fighting doesn't occur because the overlay and the cobblestone are in the same mesh and it gets simplified to remove unneeded faces.  But when you render across a chunk boundary, both faces exist in the same space and OpenGL has to render both of them, but can't z-sort them.

Ok that makes sense. So there really isn't a good way to solve this?

Link to comment
Share on other sites

offset the overlay from the block position by a tiny amount. 0.001 is sufficient.

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.

Link to comment
Share on other sites

Nope, the distance is too tiny.

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.

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.