Equivalent Exchange 3

Equivalent Exchange 3

2M Downloads

Glass Bell Render bug in inventory with special renderers

iTitus opened this issue · 21 comments

commented

When you have a Glass Bell in your inventory, you open it, the glass bell has a black 'filling'.
But only if you have one of these in your inventory and you are not hovering it:

  • Any item
  • Stained glass pane
  • Saplings
  • Fluid Blocks
  • Fire
  • Your blocks with a model

-> Everything with a special renderer

I made a picture and a video:

Link to video!

renderbug-glassbell

commented

I'm aware of the bug. I've attempted various fixes but I'm at a loss as to why this happens. I'm not a rendering guru so if anyone of you reading this are feel free to take a crack at this one

commented

I've seen this happening with Buildcraft too. I'm not sure if you're to blame here pahimar!

commented

I may look into it right now

commented

I fixed this same issue in Refined Relocation and I'll PR a fix for it now :)

EDIT: that's a lot of people suddenly :P

commented

Fixed something similar in BetterStorage with GL11.glEnable(GL11.GL_ALPHA_TEST);

commented

Yes, @Victorious3 this is it. PR: #715

commented

Hmm, to fix this I enabled GL_BLEND. Works too. Any idea on what is the 'better' fix? I'm not a rendering guru either.

commented

Probably best to use the glAlphaFunc. That fixes rendering glitches like
these
On 22 Jul 2014 16:41, "Dynious" [email protected] wrote:

Hmm, to fix this I enabled GL_BLEND. Works too. Any idea on what is the
'better' fix? I'm not a rendering guru either.


Reply to this email directly or view it on GitHub
#713 (comment)
.

commented

If it doesn't need translucent alpha (i.e. it's either transparent or opaque and nothing in between) I'd use ALPHA_TEST. If it has partially-transparent pixels, use BLEND, but it doesn't look like this does.

commented

Because blending is a thing in general: it can be alpha, multiplication and all the goodies of the fixed pipeline(in current MC case). Currently there is only alpha test leak in MC. It is bad practice to override whole context if it is not controlled, but I can be wrong :)

commented

@Itaros That's a good explanation, thanks!

commented

Blending and Alpha Testing are separate states. Blending is when there are pixels that are partially-transparent overlapping each other, and alpha testing means the renderer will test based on the binary transparent-or-opaque value of a texel before building the depth buffer.

commented

@briman0094 Minecraft uses a fixed pipeline version of OpenGL. There are no shaders. That's why there using fixed pipeline commands (e.g. glPushMatrix(), glScalef(), etc.).

commented

That's changing in 1.8, but I wasn't referring to Minecraft specifically.

commented

I thought they have inherited implementation in the driver xD

commented

Well, technically GL_ALPHA_TEST isn't used anymore if I remember correctly. I think that's done in the shader. GL_BLEND might do something; I can't remember if the shader is supposed to handle all blending functions or not.

commented

As for OGL 3.2 GL_BLEND is used to control application of A component from RGBA. Shaders nowadays define how to apply this blending: as cutout(like GL_ALPHA_TEST does in fixed pipeline) or as full-featured blending(from texture sampling).

commented

I don't have any idea if it helps but minecraft itself had and apparently has again some weird behaviour when it comes to special renderers. The behaviour of the initial bug https://bugs.mojang.com/browse/MC-35617 is very similar to this one, and it was related to overlays like stack size display and enchantments. So even if this bug is solved for now I would think that it is more of a problem in Minecraft itself, as it apparently happens for other mods too.
Im not at all a graphics specialist, so it might very well be just a simple tricky behaviour in OpenGL that just happens to work most of the time. In my opinion, the bug seems indeed like Minecraft renders the inventory sequentially and some of the visible items set GL settings that may not be fitting for the following items, and that they never get reset because they assume each item will set its rendering settings as needed.
To further improve the fix that is already merged it might be useful to get the current setting before changing it and then only setting and resetting it when needed.

commented

It's not exactly a bug...it is, but it's just on whoever wrote the item renderer. It's due to the fact that OpenGL is literally just a state machine, and they're not making sure they have the state they want before rendering.

commented

That's what it seems like, which I tried to express.