RenderModeAttrib M_wireframe transparency issue

I initially made a github issue for this, but that wasn’t the right place to be asking follow-up questions.

I’m trying to create a wireframe view of a scene, but while having the wireframe’s color reflect that of the object it’s representing is convenient, It’s a bit annoying when a wire matches transparency or a very dark color that blends into my background.
using:

self._orthoState = RenderState.make(RenderModeAttrib.make(2, 2, False), CullFaceAttrib.make(0), ColorBlendAttrib.make(5, 4, 2, 5, 8, 6, LVecBase4f(0.6,0.6,0.6,1)), AlphaTestAttrib.make(RenderAttrib.MAlways,1))

environment.egg looks like this:
image
So unfortunately, even when I try and disable alpha testing, parts of the wires remain transparent and all RenderModeAttrib.M_max does is “frost the tips” where the wires dip into invisibility.
Does anyone know how to fix this or some other way of maintaining visibility for transparent wires while otherwise matching an object’s color?

What you’re missing is an override value in your RenderState. Lower nodes in the hierarchy are therefore overriding some of the attributes. If you add a value like 1 as last argument to the RenderState.make() call, then it will work.

The lines will show up white because that is the colour of the textures in the transparent areas. Unfortunately if you’re already using the “max” blending mode you can’t also use the ColorBlendAttrib to fix this - MMax doesn’t take operands, they are ignored. So if you want to avoid the white lines, you have to (1) not use the MMax mode, but something else - like a subtractive mode that inverts the colour of the background, so you can use the operands to take the alpha into account, (2) save the textures with premultiplied alpha (so that the colour of the transparent areas is black), or (3) do this in a shader or with a texture combine mode.

1 Like