Particles + Shaders

Particles are great… they are way fast now! I’m using particles with a shader. Right now the particles are bound to a nodePath that is attached to a higher nodePath.

Question 1:
Right now if I apply a shader to a particle. The alpha in and out does not work anymore. It just pops. I have taken vertex color into account and it still pops. For some reason this only works under fixed-pipeline. Anyway to get this working for a shader?

Question 2:
Is there a way to disable shaders for a nodePath even if the parent has a shader already. Nodepath.clearShader just defaults it to the parent. I found a really dumb work-around where you assign a broken shader to the lower nodePath, but is there a more elegant way of doing this?

I believe that has a CG example of OpenGL’s fixed function pipeline. Maybe you should check that out?


NodePath.setShaderOff() will turn shaders off, overriding a setShader() call inherited from above.

I don’t know about the alpha problem. That sounds interesting. Have you found out more about that?


I had a similar problem with bumpmapping with transparant PNG files. The sample is in the code snippets forum. Dunno if it’s the right one. But maybe it’ll be some help.


it’s not the right one. I’ll update it right away



Apparently, this problem isn’t only with particles. It’s with everything.

It seems that vertex color isn’t given to the shader at all. If I call setColor on a nodePath, this does not seem to go into the vtx_color0: COLOR0 binding of the shader. I remembered this used to work in the old shader infrastructure before .sha files. It could also be the fact that I’m developing on an ATI card and not an nVidia one right now.

However, the original color from the geometry is still there. In other words if I specify the color in the geometry, it shows up.

Any work arounds for this? Granted, I could just do a setShaderInput(“vertexColor”, nodePath.getColor), but that seems rather convoluted.

Try putting:

color-scale-via-lighting 0

in your Config.prc file.

Explanation: as an optimization, Panda nowadays might choose to implement setColor() by enabling a colored ambient light on the model, instead of actually changing the vertex color. This enables the vertex buffer to be reused without modification and has other similar benefits. But obviously it screws up any shaders that expect to find the color actually on the vertices. Maybe Panda should always not apply this optimization whenever it sees there is a shader in effect.