https://github.com/KhronosGroup/OpenCOLLADA/pull/161#issuecomment-15343540
Mar 23, 2013
My contribution to OpenCOLLADA 3dsmax export
https://github.com/KhronosGroup/OpenCOLLADA/pull/161#issuecomment-15343540
Mar 7, 2013
3dsmax Light Decay (distance attenuation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline float Decay(float att,float dist, float r0) { | |
float s; | |
if (decayType==DECAY_NONE || dist==0.0f) return att; | |
if ((s=r0/dist)>=1.0f) return att; | |
return (decayType==DECAY_INVSQ)? s*s*att: s*att; | |
} | |
float BaseObjLight::ApplyDistanceAtten( float dist ) | |
{ | |
float atten = 1.0f; | |
if(ls.useNearAtten) { | |
if(dist<ls.nearAttenStart) // Beyond range | |
return 0; | |
if(dist<ls.nearAttenEnd) { | |
// in attenuated range | |
float u = (dist - ls.nearAttenStart)/(ls.nearAttenEnd-ls.nearAttenStart); | |
atten = u*u*(3-2*u); /* smooth cubic curve */ | |
} | |
} | |
if (ls.useAtten) { | |
if(dist>ls.attenEnd) /* Beyond range */ | |
return 0; | |
if(dist>ls.attenStart) { | |
/* Outside full-intensity range */ | |
float u = (ls.attenEnd-dist)/(ls.attenEnd-ls.attenStart); | |
atten *= u*u*(3-2*u); /* smooth cubic curve */ | |
} | |
} | |
// atten = Decay(atten,dist,ls.nearAttenEnd); // old way, changed by dan | |
atten = Decay(atten,dist, decayRadius); | |
return atten; | |
} |
Subscribe to:
Posts (Atom)