Game Development Community

Lighting on GL primitives in TGE

by Daniel Buckmaster · in Technical Issues · 01/22/2010 (1:09 am) · 2 replies

How would I go about getting mission lighting to affect things like fxRenderObject? At the least, I'd like triangles to shade according to sunlight. It seems that LightManager::sgSetupLights should make all the necessary calls on the GL side of things, but it's not affecting my rendered triangles. Any hints?

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
02/09/2010 (11:14 am)
Look at the bottom of TSMesh::setupMaterials();

In particular the area around the call to LightManager::sgSetupExposureRendering();

I think that may be of some help, as it appears to be lighting is setup prior to a TSMesh being rendered. The only other experience I've had with setting up lighting is in a subclass of TSCtrl where I forced some hardcoded lighting values based on some code in (iirc) ShowTSCtrl. Use find-in-files to track down some calls to glEnable(GL_LIGHTING) and work backwards from there to see how it's initialized.

If neither of those help and you figure something else out, I'd like to see how you DO do it, because I'm working on some custom objects that I'll be wanting to light.
#2
09/09/2010 (1:44 pm)
Hmm, some small progress. Adding these lines to the renderObject method:
gClientSceneGraph->getLightManager()->sgSetupLights(this);
   glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
   LightManager::sgSetupExposureRendering();
(and their corresponding opposites after rendering), I've managed to get the road to respond to dynamic lights like Projectiles and Explosions. However, it doesn't seem to receive sunlight or ambient, though sgSetupLights looks like it's all in order.

Actually... it looks like the ambient works sometimes, for some camera positions and angles. Darn. Hate those sorts of problems :P. Also, the effect is variable - sometimes it seems like full ambient, other times it's very dim. And I don't think directional sunlight works at all.