setColor() not working

Hi, I’ve been loading some 3D models without any textures for a school project. I’m trying to use setColor() to set the rgb values for the models. However whenever I use it the Colors don’t come out different, for example, 0,130,255,1 is the same as 0,255,15,1. Is there a fix for this or is this just how it is?

Greetings!

setColor() takes in values between 0.0 and 1.0

2 Likes

To add to that, in order to convert from values in the range 0…255 to the required range of 0…1, just take your value in the former range and divide it by 255.

2 Likes

Ah ok, thank you so much.

2 Likes

Will do, thank you.

1 Like

This only works if you are not using gamma-correction. If you are using an sRGB-correct pipeline, the conversion can be done using the decode_sRGB_uchar function:

from panda3d.core import decode_sRGB_uchar as dc

np.set_color(dc(127), dc(127), dc(63), 1.0)

This should not be done for the alpha channel.

3 Likes