Fbx light attenuation

Started by
3 comments, last by Alundra 8 years, 8 months ago

Hello,

I'm currently adding light attenuation to my shaders. (forward rendering)

The formula I'm using is the following:

attenuation = 1 / (attConst + attLinear * dist + attExp * dist * dist);

Now the real problem is how to put Fbx values in relation to that formula.

So far I have plugged what fbx call DecayStart as my attExp variable. It seams DecayStart is in the range 0..100 so I'm multiplying it by 0.01

Now I think this is not really what maya or 3dsMax are doing...

Fbx has also:

NearAttenuationStart

NearAttenuationEnd

FarAttenuationStart

FarAttenuationEnd

So now I'm really not sure how to compute all those, I mean I could invent something of course but I'd prefer something that is commonly used.

Is there a new attenuation formula I should use ?

Does anybody know Fbx enough to teach me how to plug all those variable together in a nice attenuation function.

Thx a lot.

Advertisement

Woah, nobody's working with Fbx anymore ?!?

Or I am completly out of subject here ? Just let me know if my post needs more precision or anything that would help.

On the same register, my tech artist is saying that EmissiveFactor from Fbx is modulating the diffuse, so what is lighted is even more bright but then what is the DiffuseFactor in that case ?

When an artist is putting Emissive factor what is his ojective ? Same question for DiffuseFactor then.

Cheers !

Using "Start Attenuation" and "End Attenuation" you can compute the attenuation factor using smoothstep :


float3 LightDirection = Light.Position - SurfaceData.Position;
float d = length(LightDirection);
float Attenuation = smoothstep(Light.EndAttenuation, Light.StartAttenuation, d);

But on the FBX doc I see the Decay param which contains : None, Linear, Quadratic and Cubic.


None = No attenuation
Linear = lerp(Light.EndAttenuation, Light.StartAttenuation, d);
Quadratic = 1.0f / dot(Attenuation, float3(1.0f, d, d*d));
Cubic = ?

From a paper of Unreal Engine 4, here the formula used :


float Factor = clamp(1.0f - pow(d / Light.EndAttenuation, 4.0f), 0.0f, 1.0f);
float Attenuation = (Factor * Factor) / ((d * d) + 1.0f);

Thank you for your answer. I'll have to do some tests. I'm guessing the pow(4) in unreal is for the cubic attenuation right ? I just don't like the magic numbers.

This is the physically accurate inverse square falloff.

The 1 in the denominator is there to prevent the function exploding at distances close to the light source.

You can get more information there : https://de45xmedrsdbp.cloudfront.net/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf

This topic is closed to new replies.

Advertisement