Author Topic: lighting mode and ambient light  (Read 2455 times)

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
lighting mode and ambient light
« on: September 24, 2010, 08:39:55 pm »
i need to set ambient light to a high value to make details of textures visible. but in that case i cant properly set color of glow planes. -i guess- because of over lighting they seem white. and seems as calling

Code: [Select]
Object3D.setLighting(Object3D.LIGHTING_NO_LIGHTS);
has no effect with ambient light. so what can i do in this case except changing ambient light ?

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: lighting mode and ambient light
« Reply #1 on: September 25, 2010, 01:29:53 am »
some images will make things clearer:

this is how it looks at the moment. i want this glow look green (via setting additional color). transparency mode is additive and ambient light is kind of high:


same ambient light but with transparent mode default. looks kind of green but we lost brightness because of default transparency mode.


low ambient light and transparency mode default. definetely looks green but no brightness and textures don't look good.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: lighting mode and ambient light
« Reply #2 on: September 25, 2010, 01:38:14 am »
What color and shade is the original png image, and what shade are you using for the additional color?  I would try starting with a darker green png image for the texture and using a darker green for the additional color as well to see if you can get it down to the total brightness and color you are looking for.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: lighting mode and ambient light
« Reply #3 on: September 25, 2010, 02:02:57 am »
i'm using a white image. indeed it's your glow image converted to white. additional color is green. even with a very dark image like below, the glow seems white with transparency mode add and high ambient color ???



glow with image above.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: lighting mode and ambient light
« Reply #4 on: September 25, 2010, 02:15:39 am »
The reason for this problem, of course, is that with additive color you are adding the color of the transparent image to the existing color, so even a dark color causes the area to approach white very quickly when the color you are adding it to is already bright to begin with.  Another thing you could try is two layers for your glow effect.  The first you would use normal transparency mode to shade the area closer to the target color.  Then placing the texture with additive transparency over that won't require as much additional color to reach your target color, so hopefully it won't end up looking as bright/white.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: lighting mode and ambient light
« Reply #5 on: September 25, 2010, 02:30:08 am »
i see, thanks. but that two layers of glow will have its own difficulties. they cant be just simple billboarded quats. i need to place them according to camera each frame such that one is behind other all the time. not too difficult but not that simple too.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: lighting mode and ambient light
« Reply #6 on: September 25, 2010, 03:35:39 am »
One billboard quad could be the child of a second billboard quad, both with the same center/pivot.  The polys of the outer layer would consist of vertices with lower values for z (or higher, depending on which side billboarding points toward the camera in jPCT) than those of the inner layer.  Then you would give the parent object normal transparency and the child object additive transparency.

--EDIT--
I should point out in case you haven't noticed already, jPCT automatically calculates the center/pivot of a quad to have the same z-value as the polys when the object is built.  One work-around to "trick" jPCT into using a different center is to add two additional back-faced polys (on the other side of the imaginary "cube").  In my above scenario you could leave the parent object as 2 polys and just add a the extra polys to the child object.  An alternative to adding polys is with translateMesh, I believe, however as I recall it will just revert back if you call build or buildAll afterwards.
« Last Edit: September 25, 2010, 03:50:40 am by paulscode »

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: lighting mode and ambient light
« Reply #7 on: September 26, 2010, 12:24:49 am »
yeap, i suppose parent child relation will greatly ease calculation. or i guess alternatively a simple object with two parellel quads will also do the job.

i couldnt get your idea to trick jPCT ??? isnt setRotationPivot method enough to set rotation pivot ?

i wish this has an easier solution with color settings ::)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: lighting mode and ambient light
« Reply #8 on: September 26, 2010, 01:34:48 am »
Right, but jPCT doesn't use the rotation pivot for the billboard effect.  Instead, it uses the object's center-of-mass, which is apparently calculated when the object is built.  This can be changed either by making the object have more volume by adding polys or by translating the mesh after building.

For the color settings, you would need to somehow specify negative values for the additive transparency mode - you want to add some green after subtracting a bit of red and blue, so the resulting effect is brighter than the initial colors, but not in a way that makes it look white.  I'm not sure if there is a one-step way to do that.
« Last Edit: September 26, 2010, 01:40:31 am by paulscode »

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: lighting mode and ambient light
« Reply #9 on: September 26, 2010, 11:43:49 pm »
thanks paul ;D i wasn't aware of that. as you suggested, i've played with color of glow plane and results looks better now.