Game Development Community

Multiple lights and custom shader

by Gabriel Notman · in Torque Game Engine Advanced · 07/05/2007 (10:25 am) · 3 replies

I was just wondering how to get the information on the different light sources affecting a particular object.

Looking at the shdrConst.h:

//---->ShdrConst.h
#define VC_LIGHT_POS1 C23
#define VC_LIGHT_DIR1 C24
#define VC_LIGHT_DIFFUSE1 C25
#define VC_LIGHT_SPEC1 C26

#define VC_LIGHT_POS2 C27
//#define VC_LIGHT_DIR2 C28
//#define VC_LIGHT_DIFFUSE2 C29
//#define VC_LIGHT_SPEC2 C30
#define VC_LIGHT_TRANS2 C31

There is all the information on light source 1, and some information on light source 2.

If there are more then 2 lights hitting an object, how do I get the information on the other light sources?

Is each light done with a separate pass? If so what is the secondary light source used for?

I've had a look at the topic on: Interior Light Information to Custom Shader
www.garagegames.com/mg/forums/result.thread.php?qt=63295

however the
-getDynamicLightingCoord ... method mentioned there requires the position and matrix of the light sources.

The procedural textures, seem to correctly calculate the lighting including specular from several sources. How can I duplicate such with a custom shader?

Gabriel

#1
07/06/2007 (9:41 am)
Custom materials render each light in a separate pass and the engine manages the passes for you. Once your custom shader is up and running and supports point lights (has a point light specific version assigned to its dynamicLightingMaterial member) it will automatically support multiple light sources.
#2
07/06/2007 (1:58 pm)
Sorry, could you clarify that a bit. I currently have a custom shader which relies on light1 position direction for calculating specular etc. So if access the dynamic light materials as in the TDN article referenced in the above mentioned thread, the engine should execute a render pass using my custom shader for every active light?

Gabriel
#3
07/11/2007 (3:01 pm)
Yes, but you can't apply the material directly to the object - instead create a directional/sunlight version of the custom material (this requires another custom shader) - this is considered the "main" or "root" material. Then assign your point light material to the main/root material's dynamicLightingMaterial property.