Adding specular scale to light entities?
by Felix Willebrand Westin · in Torque 3D Professional · 04/27/2014 (3:06 pm) · 0 replies
Hi all!
I'm trying to add a specScale value to light entities and tie it into the rendering system to be able to control specular highlights of individual light sources.
I've added the variable to the lightBase class and set up all the functions for setting/reading it, however I'm having some trouble working out the shader part.
For now I've simply set up pointLightP.hlsl to do:
with lightSpecScale being the new variable.
This obviously doesn't work however as the variable doesn't seem to be set (this is what I don't know how to work out).

(specular term just shows up black leading me to believe the variable is uninitialized)
I've added the variable to the function parameters like so (pointLightP.hlsl):
however the rather humble coder inside me tells me that somewhere this function is called and I need to change this too but I cannot for the life of me figure out where that is.
If someone could help shed some light (no pun intended) on the lighting system in Torque, specifically how the C++ code interacts with the HLSL part that would be very much appreciated.
Thanks!
I'm trying to add a specScale value to light entities and tie it into the rendering system to be able to control specular highlights of individual light sources.
I've added the variable to the lightBase class and set up all the functions for setting/reading it, however I'm having some trouble working out the shader part.
For now I've simply set up pointLightP.hlsl to do:
// Specular term float specular = AL_CalcSpecular( lightVec, normal, normalize( -eyeRay ) ) * lightColor.a * lightSpecScale;
with lightSpecScale being the new variable.
This obviously doesn't work however as the variable doesn't seem to be set (this is what I don't know how to work out).

(specular term just shows up black leading me to believe the variable is uninitialized)
I've added the variable to the function parameters like so (pointLightP.hlsl):
float4 main( ConvexConnectP IN,
uniform sampler2D prePassBuffer : register(S0),
#ifdef SHADOW_CUBE
uniform samplerCUBE shadowMap : register(S1),
#else
uniform sampler2D shadowMap : register(S1),
#endif
uniform float4 rtParams0,
uniform float3 lightPosition,
uniform float4 lightColor,
uniform float lightBrightness,
uniform float lightSpecScale, <---
uniform float lightRange,
uniform float2 lightAttenuation,
uniform float4 lightMapParams,
uniform float4 vsFarPlane,
uniform float3x3 viewToLightProj,
uniform float4 lightParams,
uniform float shadowSoftness ) : COLOR0
{
...however the rather humble coder inside me tells me that somewhere this function is called and I need to change this too but I cannot for the life of me figure out where that is.
If someone could help shed some light (no pun intended) on the lighting system in Torque, specifically how the C++ code interacts with the HLSL part that would be very much appreciated.
Thanks!
About the author
Hobbyist turned game dev. Worked at DICE for a short while, now working on personal stuff and Dota 2 things.