Game Development Reference
In-Depth Information
Some Notes on Lighting in OpenGL ES
While lighting can add some nice eye candy to your games, it has its limits and pitfalls. Here are
a few things you should take to heart:
Lighting is expensive, especially on low-end devices. Use it with care. The
ï?®
more light sources you enable, the more computational power is required to
render the scene.
When specifying the position/direction of point/directional lights, you must
ï?®
do it after you have loaded the camera matrices and before you multiply
the model-view matrix with any matrices to move and rotate objects
around! This is crucial. If you don't follow this method, you will have some
inexplicable lighting artifacts.
glScalef() to change the size of a model, its normals will
also be scaled. This is bad because OpenGL ES expects unit-length
normals. To work around this issue, you can use the command
glEnable(GL10.GL_NORMALIZE) or, in some circumstances,
glEnable(GL10.GL_RESCALE_NORMAL) . We'd suggest sticking to the former,
as the latter has some restrictions and caveats. The problem is that
normalizing or rescaling normals is computationally heavy. For optimum
performance, it's best not to scale your lit objects.
When you use
ï?®
Mipmapping
If you've played around with our previous examples and let the cube move further away from the
camera, you might have noticed that the texture starts to looks grainy and full of little artifacts
the smaller the cube gets. This effect is called aliasing , a prominent effect in all types of signal
processing. Figure 11-8 shows the effect on the right side and the result of applying a technique
called mipmapping on the left side.
Figure 11-8. Aliasing artifacts on the right; the results of mipmapping on the left
 
Search WWH ::




Custom Search