angularAttenuation in Spotlight differs from spec. recommendation
andreasplesch opened this issue · comments
recommends squaring the cosine interpolation:
angularAttenuation *= angularAttenuation;
while the viewer uses smoothstep
smoothstep is using Hermite interpolation which also squares but has additional terms (https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml).
The difference is probably minor and the spec. does not actually require following its recommendation, only something similar.
But since the sample viewer is the reference glTF implementation, this difference still creates (slight) confusion.
I suspect smoothstep
was chosen because it is really convenient and perhaps a bit faster. So perhaps that is really an issue for the spec. which could update its recommendation. Or the viewer could follow the spec. but leave the smoothstep
alternative commented in the code because it seems more elegant and is conforming.
KhronosGroup/glTF@34ae110
introduced the spec. recommendation in 2018.
47a686c
introduced smoothstep later in 2018, perhaps in response to the spec. change.
A quick gltf (
spotlight_gltf.zip
) with a single spotlight shows the visual difference:
where
{\n
// return smoothstep(outerConeCos, innerConeCos, actualCos);\n
float anAt = (actualCos - outerConeCos)/(innerConeCos - outerConeCos);
return anAt * anAt;
}
was edited in as a devtools override.
smoothstep shows less falloff closer to the innerAngle. It is more noticeable than I thought.
has a PR for above if of interest.
#488 has been merged