Game Development Community

Where is lightinfoUncondition defined?

by Tim Dix (Raverix) · in Torque 3D Professional · 07/28/2010 (10:48 pm) · 6 replies

Hello, I'm trying to figure out the shader system inside of T3D, and I see a lot of the procedurally generated shaders makes calls to lightinfoUncondition, such as:

lightinfoUncondition(tex2D(lightInfoBuffer, uvScene), d_lightcolor, d_NL_Att, d_specular);

But I cannot fond this function defined in any file. Is there some voodoo that's defining it runtime before compilation or am I just failing grep today?

#1
07/29/2010 (12:29 am)
Alright, well, it looks like it's a Macro... and something somehow is supposed to trigger T3D into including it when it's compiled... make sense to anyone?
#2
07/29/2010 (1:34 pm)
It is generated by the engine and should be in autogenConditioners.h alongside the other procedural hlsl files. It won't be there if you're using Basic Lighting, though.
#3
07/29/2010 (3:46 pm)
It's located in autogenConditioners.h but it will not be named 'lightinfoUncondition' in that file, instead it will be a hash of the features used to generate the Condition/Uncondition pair of functions.

When a target is bound to the material system, such as the 'lightinfo' target(as either input or output), the material system will compile the shader with a pre-processor define that connects 'targetnameCondition' and 'targetnameUncondition' to the hashed function names.

If you open autogenConditioners.h you should see comments which indicate what is going on.
#4
07/30/2010 (2:52 am)
Ah, got it. Well, then what's the proper way to reference them from my shader? For right now, I've just copied the function into my shader as

inline void lightinfoUncondition(in float4 bufferSample, out float3 lightColor, out float NL_att, out float specular)
{
   lightColor = bufferSample.rgb;
   NL_att = dot(bufferSample.rgb, float3(0.3576, 0.7152, 0.1192));
   specular = max(bufferSample.a / NL_att, 0.00001f);
}

But from what you've said, that's not right because that function can change, and then my shader will be out of sync with the rest of the lighting?
#5
07/30/2010 (4:19 pm)
It is very likely that that particular function will not change. The conditioners are used most in the Gbuffer, they would only be used for different color spaces for the lightinfo buffer, and that's not something that will be a concern unless you go and make the changes yourself.
#6
08/07/2010 (7:42 pm)
I'm confused as to the rationale behind this? Since autogenConditioners.h is being generated, couldn't the generated function simply be named lightinfoUncondition, etc, and then you wouldn't even need the T3D code that maps lightinfoCondition to the hashed name?