Diffuse coloring

Started by jpctnewb, June 03, 2005, 04:57:51 PM

Previous topic - Next topic

jpctnewb

Hi all - I'm new with jPCT and I'm trying to figure out how to modify the diffuse color for, let's say, a given primitive.  Does anyone know how to do this?

EgonOlsen

setAdditionalColor(...) in Object3D should do the job.

MichaelJPCT

i went into the same issue. i tried setAdditionalColor, but it can not simulate a material with diffuse lighting.
for example, i have an object without texture, if object.setAdditionalColor(0,0,0) and sun color is (255,255,255), when a polygon faces the sun directly, the polygon is pure white. it almost looks like specular, but it shouldn't be.
i want a black polygon to look gray when it faces the white sun. what can i do? must i use shader?
PS: the sun is a Light which is placed far away, and never fades.

EgonOlsen

setAdditional color sets an additional color, i.e. it adds the color. In jPCT, there is no such thing as an object without a texture. Even objects without an actual texture assignment have a texture, in this case a white one. Adding any other color to white doesn't change anything, because it won't get whiter than white. A light source's color gets multiplied with the texture color, i.e. you can't light up an object textured with in pure black, because 0*something is still zero. That's the way in which the default OpenGL lighting pipeline works. If you want something different, you have to use shaders...or somehow adapt to it's behaviour. In your case, I suggest to texture the object with a color that is almost black. You can use the Texture(width, height, color) constructor for that. Just create a small 8*8 texture with maybe 10,10,10 as a color and see if that gives you the desired results.

MichaelJPCT

it works. thanks.
and the Texture constructor is so convenient that i can easily create a collection of colors.