can't seem to force objects to render opaque

I am loading geometry to be rendered using render-to-texture, and applying a CG shader to it. The geometry does have transparent alpha in both the vertex color and the texture, but I am using them for another purpose in the shader, it is not supposed to render transparent. There are a few other objects in the render-to-texture scene that do not have a shader applied.

Now the problem: pstats reports that the majority of the render time for the render-to-texture is being spent on rendering transparent objects. I discovered the problem when i tried to add some particles to the scene and they had some bad transparency issues such as often the geometry behind the particle would not render. Note that the pstats results were before adding any particles, they are not the cause.

The shader explicitly sets the output color to be opaque:

o_color = float4(p_lit.rgb, 1.0);

This is basically how I’m loading it:

node = NodePath('new render')
node.setAntialias(AntialiasAttrib.MNone)
model = loader.loadModel(modelpath)
shader = Shader.load(shaderpath)
model.setShader(shader)
model.reparentTo(node)

I also tried:

model.setDepthWrite(True)
model.clearTransparency()

I must be missing something here, any ideas?

Try:

model.setBin('opaque', 0, 1)

to force the model into the opaque bin.

David

That’s done it! It significantly improved the draw time too.
Thanks again.

Actually, thinking on this later, a better answer would be to do:

model.setTransparency(TransparencyAttrib.MNone, 1)

which not only puts the model in the opaque bin, but it also actually disables the transparency state. But if you have your own custom shader applied, then the transparency state doesn’t matter anyway (because the shader fully determines the rendering state).

David

Interesting.
I had actually tried setTransparency before without the priority flag and it had no effect, but with the priority it does work.