This "Falloff" you're talking about..
Does your use of the word "Falloff" mean the distance between the light
and the fragment (surface), or does it refer to the "Sharpness" of your Specular Highlight? (glass in helmet)
Just asking because I've seen it mean two things..
If your "Falloff" is related to "Distance from Light to Surface" then it may mean that your light would have a MAX Spherical Radius
so that you can have a curve (squared or linear) between ZERO and Max Distance.
If this is the case then your curve might drop off "suddenly" at Max Distance.
(I don't think matrices would cause this)
I don't know if it will help but here is a snippet from my shader that deals with this falloff..
Code: Select all
// You should have calculated "LDist" allready.. Something like this:
float3 LFDeltas = LightsPosArray[LghtI].xyz - IN.PassedWORLDVertPos.xyz; // O.K.
float LDist = sqrt ((LFDeltas.x * LFDeltas.x) + (LFDeltas.y * LFDeltas.y) + (LFDeltas.z * LFDeltas.z)); // Pyth..
// In the real world a light has a VERY VERY far max radius, but in CG we have to give it a definite MAX..(we don't want an infinite sphere)
CurvedIntensity = 1.0 - (1.0 / LightsMaxRadiusArray[LghtI] * LDist); // You know what your light Max Radius is..
CurvedIntensity *= CurvedIntensity; // Squared for the curve.. (Even without this a linear value should be Zero at Max Dist)
// = = other code = = =
// Additive Diffuse (looping though lights with "LghtI")..
FinalRGB += CurvedIntensity * (MappedDiffuse.xyz * (max(dot(FinalNormal, // DIFFUSE PART..
(normalize(LightsPosArray[LghtI] - IN.PassedWORLDVertPos))),0.0)
* LightsColArray[LghtI] * PassFloatArray [FAI_000_GLOBAL_BRIGHTNESS] ));
// Additive Specular (looping though lights with "LghtI")..
FinalRGB += CurvedIntensity * (clamp(pow(clamp(dot(normalize(( normalize(CameraPos - IN.PassedWORLDVertPos)
+ normalize(LightsPosArray[LghtI] - IN.PassedWORLDVertPos))),
FinalNormal),0.0,1.0), 7.777 ), 0.0 , 1.0) // 7.777 is just an example of your Specular "Tightness".. * difficult to control with maps..
* LightsColArray[LghtI] * MappedSpecular.x) * 1.0;
See how both Specular and Diffuse was multiplied by this curve..
Ignore the Mapped stuff but understand how Curved Intensity is created and used.
I don't know about your Matrices but I do know that RenderMonkey uses a totally
different setup than what is needed in Irrlicht (for me at least).
It does not use Camera Position, Camera Target and Geometry Position.
It simply rotates the object or orbits the camera which isn't good enough
for where we have a world of moving lights and rotating objects and cameras.
(this is why its matrix setups are lacking)
Oh, I'm sure your Normals are "Normalised"..
If you use a totally different procedure then I don't know buddy..
You could look at my latest post and others where we discussed this because those matrices work for my HLSL shader.
The reason I asked if you could compile standard Irrlicht stuff is because most of my old posts use Vanilla Irrlicht
and I think that if you compiled at least one of them successfully you'd have a good grip on this.
I'm busy with a set of batch files that puts my whole work desk in either Vanilla or Custom mode..
(copying, and overwriting Headers, LIBs and DLLs etc). Anyhow you will find a solution.
Cheers! Master Chief looks nice and polished!