Vertex painting and lighting

If I vertex paint a model in Blender run it in Panda without any lights the model renders as painted. As soon as I add lights to the render node, all the vertex painting seems to be ignored… a vertex painted bright renders the same value as a vertex painted black. Is there a setting that allows painted vertices to keep their values?

In Blender, unwrap your model and save the vertex paint you did as a texture.

Thanks. Hadn’t thought of that.

or simply turn off the lights on that particular model.

ColorAttrib.makeVertex() seems to work in part. I can’t save the texture because it is the verts that are painted, and the texture is being tiled across a larger plane. Turning off the lights does seem to be the best option but it means I cannot use normal maps to effect. I guess I’ll have to look into shaders.

If turning on the lights changes the color, it means you have a MaterialAttrib with an explicit color set. Remove the MaterialAttrib (or remove the entry from the egg file), or remove whatever it is in the Blender file that creates the entry in the first place.

David

The model has textures applied to it. What I am trying to do is paint tonal values onto the model as grayscales by painting vertices. what I think is happening is that light values are added to existing vertex colors, so if a light shines on it then even if it is painted black it is going to render as lit. What I think I need is a shader to use the vertex colors to modify how the light is applied, so, for example, if the vertex is black, then no light is applied, if a vertex or fragment is gray then the amount of grayness defines how much light will be applied, if a vertex or fragment is white then all the light (as it is set) will be applied.

No, light values will multiply on existing vertex colors, not add. What is happening is that there must be a MaterialAttrib on the surface, which specifies a specific color.

A MaterialAttrib, when applied, is in effect only in the presence of lighting. Some MaterialAttribs allow the vertex color to be seen, but others specify a specific RGB diffuse color, which replaces the vertex color when the MaterialAttrib is in effect (i.e. when lighting is enabled).

So, remove the MaterialAttrib, or remove the tag which created it.

David

Thanks David, you’re right they are multiplied. I can’t see how to remove the material from the model and retain the texture, but I have found the VColPain settings button in Blender’s material panel which replaces material colors with vertex colors.

We’re still not quite speaking the same language. When I refer to a MaterialAttrib, I’m referring to the Panda construct, not anything in Blender. A MaterialAttrib in Panda has nothing to do with texture. You can remove the MaterialAttrib from the model after you have loaded it into Panda, like this:

model = loader.loadModel('mymodel.egg')
model.setMaterialOff(1)

Having done that, you can then light the model without losing its vertex color.

Or, you can hand-edit the egg file and remove the entry and/or the entry within each polygon, which ensures that the MaterialAttrib doesn’t get created in the first place.

I don’t know why the Blender converter decided to create a entry that replaces the vertex color when you this isn’t what you intended. That’s a different question, but I know nothing about Blender.

David

To clarify what the original poster needed to do to solve this:

When the Chicken Exporter has produced an Egg file, edit the file wherever it has a material entry as such
Material {
diffr {0.0467988923192}
diffg {0.637426972389}
diffb {0.280413120985}
specr {0.25}
specg {0.25}
specb {0.25}
shininess {12.5}

and just remove the diff… lines, eg to leave

Material {
specr {0.25}
specg {0.25}
specb {0.25}
shininess {12.5}

and then when Panda3d lighting is used, the vertex painting will show together with the textures.

Detailed explanation:
In Blender, textured polygons have a Material assigned. The texture is always connected to this Material. The Material also always has an underlying diffuse colour. The Chicken exporter exports the material’s properties even when the material is connected to a UV texture.
When Panda3d displays a lit object with a Material which specifies a diffuse colour, that colour is shown and any vertex colours are ignored. By editing as I describe you remove the diffuse colour of the material. Panda will still obey the other attributes (specular, shininess etc) as well as display the UV texture.

PS I know this is an old thread.:slight_smile:

I recently submitted a change to YABEE that makes the export omit the diffr, diffg and diffb lines when “Vertex Color Paint” is selected in the Blender material settings, so that the vertex color will be used, just like how it works in Blender.