Revision as of 00:29, 2 February 2013 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This section covers the basics of vertex lighting in jPCT. It doesn't cover topics like texture baked lighting, per pixel lighting etc.

Ambient lighting

World has a method to set ambient lighting. Usually, the values are in the range of 0..255, default is 100 for all three components for newer versions of jPCT and -100 for older ones. Negative values once had a purpose, but not anymore. Please ignore them. You may set values higher than 255, but that shows effect only when using the software renderer. If you want to look software and hardware as similar as possible, then don't do it.

Object lighting

An Object3D is lit by the World's ambient light, the light from the light sources in the scene and it's additional color setting (plus the texture color of course). In addition, you can enable specular lighting on an object. If your objects are painted in black, increase the world's ambient lighting or give the object an additional color to actually see something.

Light sources

jPCT supports an unlimited number of light sources for both, the software and the hardware renderer. However, when using Compiled objects, the number of lights that shine on one object is limited to 8. jPCT will determine the 8 most important ones for this object automatically. Lights can be added to the world in two different ways, the legacy way and the more object oriented way. I prefer the latter, which is enabled by using the Light-class in the util package. The same is true for setting up attenuation and similar may either configure this in a global way in Config or individually in either World or in the Light-class. Again, i prefer the latter way. The Config-settings are a relic from the past, ignore them for new applications if possible.

The Lights-class

Yes, Lights(!) not Light. Lights is actually a class that World uses internally. It's public only because of two methods that enable/disable overbright lighting and rgb scaling. Overbright lighting is supported by the software renderer only. If you are using OpenGL only, it doesn't matter. If you are using software and OpenGL, consider to disable it to make both renderers behave the same regarding lighting. Rgb scaling however is another story. I prefer to set it to 2 to make colors look more vivid. There are three different settings, 1,2 and 4. 1 is default, all colors are displayed as calculated. 2 multiplies the final output with 2 and 4...well, you guessed it. Rgb scaling has two drawbacks: It reduces accuracy and you may get some subtle color banding. If you don't post process the rendered image, you'll hardly notice that. And some older drivers don't support it (like old drivers for Geforce2 based cards). Updating the drivers may help in that case.

Performance issues

The more lights, the slower the rendering. It's that simple. Don't use more lights than you have to.


This is a value to tweak jPCT's lighting calculations without changing all lights settings. Software and hardware renderer behave slightly different if this value is larger than 1 (default is 10). If you are using compiled objects, jPCT will set this value to 1 anyway. So if your scene gets pretty dark after compiling your objects, this may be the reason. In most cases, it helps to increase the lights' intensities to compensate for this effect. If your light had an intensity of (10,10,10) with the default setting of Config.lightMul, this is equivalent to a lightMul of 1 and an intensity of (100,100,100).