Author Topic: Diffuse coloring  (Read 2398 times)

Offline jpctnewb

  • byte
  • *
  • Posts: 1
    • View Profile
Diffuse coloring
« on: June 03, 2005, 04:57:51 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Diffuse coloring
« Reply #1 on: June 03, 2005, 06:50:03 pm »
setAdditionalColor(...) in Object3D should do the job.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: Diffuse coloring
« Reply #2 on: July 01, 2016, 12:25:03 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Diffuse coloring
« Reply #3 on: July 01, 2016, 12:51:09 pm »
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.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: Diffuse coloring
« Reply #4 on: July 01, 2016, 06:49:24 pm »
it works. thanks.
and the Texture constructor is so convenient that i can easily create a collection of colors.