Hi, I have been writting my own shaders, how can I detect if a model has vertex colors or texture colors in panda3d side, so I can apply or vertexcolor.sha or texcolor.sha?
I know this is possible since automatic shader generation would need this feature, and which maybe it involves the model egg file, the “texture” comment which appears sometimes if the file has texture, i would only need to check if this comment is present, so if not, I could just use an else statement to use vertex colors.
You can check whether a texture is applied fairly easily:
if model.findTexture('*'):
print "texture is applied"
Checking whether vertex color is applied is more difficult. Strictly speaking, vertex color is always applied, but often the color is just white. So in order to determine whether vertex color is relevant, you will have to examine all of the vertex colors and see if any of them are non-white.
Note that the use of texture doesn’t preclude the use of vertex color. One model might have both applied simultaneously.
Hi, thanks for the help. How would I check if findTexture returns none?
I tried “== 0”, “== 1”, “!= ‘none’”, “!= ‘None’” and other ways, but I haven´t been sucefull, I always receive in terminal “Tex”, which means the value comparation is wrong, since some character parts are only vertex colored(i checked the egg file, they have no texture):
for part in playerParts:
x = part.findTexture('*')
if x != 0:
print "Tex"
else:
print "Vtx"