ShaderGenerator ignores vertex colors

I recently noticed that vertex colors are completely ignored when I switch on ShaderGenerator (on render). As our map models use vertex colors extensively for shadows, it immediately caught my eye.

The manual explicitly mentions that vertex colors are supported by the ShaderGenerator, so I’m afraid there might be some bug (which appeared after the manual page was written?).

I then tried exporting a model from Blender which had vertex colors and here’s what I got from rendering it normally and then with the shader generator:

There are some obvious differences.

Vertex colors are supposed to be supported by the ShaderGenerator, but you have to observe a rule that you might not be aware of when constructing your geometry: in order to render vertex colors, you need to apply a ColorAttrib::make_vertex() attrib to the render state. One easy way to do this is to call model.setColorOff() (that is, turn off scene graph color, and let vertex color be visible).

In the fixed-function renderer, vertex colors will render with or without this attrib, so you might not notice if you fail to apply it.

However, models that come in via the egg loader should have this attribute correctly applied, so I’m not sure what’s going on with your Blender model. It also doesn’t look like it’s completely ignoring vertex color; this might be a different problem that your original problem.

David

You’re right, I did not know that and the models were not in egg. It seems correct now. Maybe I could add this info to the manual?
However, the model from the image is in egg. I’m sure you can see the difference between fixed-function and shader in the image.

Yes, please feel free to add the information to the appropriate place in the manual.

Can you post your egg file so I can try to reproduce the problem?

David

OK, I’ve added the info you gave here: panda3d.org/manual/index.php … _Generator
I think fog and texgen modes should be removed from the missing features list as they have been added for 1.8.

Here are some example eggs: 4shared.com/file/W5SFNTkm/eggs.html

Hey, the above solution doesn’t work if ‘basic-shaders-only’ flag is set to False.

from panda3d.core import *
loadPrcFileData('', 'basic-shaders-only 0')
import direct.directbase.DirectStart

render.setShaderAuto()

mdl = loader.loadModel('test')
mdl.reparentTo(render)
mdl.setColorOff() # for vertex colors and ShaderGenerator

run()