09th / YABEE

Export models from the Blender to Panda3D game engine
MIT License
107 stars 39 forks source link

Make shadeless materials work when no lighting is applied #8

Closed rdb closed 9 years ago

rdb commented 9 years ago

This is sort of an extension of the previous patch: I realised that since this model used only shadeless materials, it'd be nice if it still worked when having lighting disabled. So, it also writes the shadeless color to the polygon colors - the .egg loader automatically notices that all polygons have the same color and turns it into a single setColor call at the node level. (When I enable lighting, Panda replaces this color with the material, which emulates the shadeless mode using the emit color, as per my previous patch. This way, shadeless materials work when lighting is enabled and when lighting is disabled.)

What this patch also does is disable vertex colors when the material has "Vertex Color Paint" disabled. This is necessary with my shadeless materials because Panda otherwise causes the vertex color to override the polygon color, when lighting is disabled. (In Blender, it seems vertex colors aren't used unless you have Vertex Color Paint on anyway). I think this should be fine, but if you don't like this behaviour, I could change it so that the change only affects the "shadeless" case; up to you.

09th commented 9 years ago

Thanks! I'am not using this feature before, so can't say anything pro or cons ) Just merge it )