Closed WrathfulSpatula closed 3 years ago
I might have been motivated, originally, by some confused idea of crystal properties like lattice spacing underlying a potential barrier at a surface where the index of refraction abruptly changes. First of all, this would be a totally wrong approach for highly reflective metals, where lattice structure might be amorphous and conduction and valence bands overlap. Secondly, if we use the concept of "smoothness," we barely need to think about a micro-mechanical picture at all.
I have it right, that both specular and diffuse reflections effectively have twice the Doppler shift of emissive lighting. Relativistically, I think this is the only new "wrinkle" we need to consider on top of common treatments of specular reflection, unless normal vectors pose another one we haven't yet factored. "Smoothness" implies two modes of reflection, "rough"(/diffuse) and "smooth"(/specular). All reflected light returns to the camera by one or the other of these means, and the specular component is subtracted from the total to give the diffuse component, (or vice versa). For a perfect relativistic mirror, (or a "perfectly rough, perfectly white" surface,) we just need to remember the double Doppler shift, as if the true source of the reflected light appears to approach us twice as fast in the mirror, (even if that exceeds the speed of light, with no problem).
On second thought, the index of refraction approach might have been not a horrible idea, in frustration. For one thing, I think it naturally encapsulates the Fresnel effect. Its biggest downside is probably the intensive trigonometry in the fragment shader, but it might not be a horrible approach. It does look "flat," though, and it could use specular highlights.
We're using Schlick's approximation, now, which produces Fresnel-effect-like behavior, but it doesn't complicate the considerations with a "transmitted" complement to the reflected component, or tons of trigonometry. I think the specular reflections are acceptable, for now.
Actually, there are a couple of additional considerations for specular reflections.
For a static/stationary mirror, a baked light probe is equivalent to the perspective it would see if it were an independent player controller. A real-time mirror will reflect the Doppler shift from the player's perspective, which is probably typically the opposite of the Doppler shift the player would see in the mirror. For example, as a player moves forward towards a mirror, as they recede from a wall behind themselves, they approach the reflection of that same wall in a mirror, effectively twice as fast as they physically recede from the wall. Reflection probes should be able to capture this effect, but it doesn't seem like they do, yet.
The issue with reflections might be that IR and UV textures are not sampled. I'm leaving this issue open while I think about how we might capture these in reflection probes.
If we don't rely on textures for UV and IR radiation, (but rather use quasi-realistic values guessed from the visual range frequencies,) we don't have to worry about sampling from 3 textures for specular reflection or any lighting effect. We give the option to use either textures or a plausible guess based on the albedo.
The calculated Doppler shift for specular reflection seems way undersized. Maybe I'm not understanding the pipeline, but baked reflection probe colors don't seem to change at all, even though Doppler shift is applied after reflection probe sampling. There might be a nuance to this that I'm missing, besides the squared Doppler shift factor.
Hah... The "nuance" would be attaching a RelativisticObject instance to my reflecting object. 😄
I'm adding an option to correct real-time reflections, and I'm pushing this up.
Actually, there's no easy way to fix the Doppler shift for real-time reflections. In the case of baked reflections, the light probe bakes at rest with respect to the world coordinates, and the squared Doppler shift applied next is correct. For real-time reflections, we can't just revert the player-perspective Doppler shift that the probe sees, (at least without a custom probe,) because the reflected line of sight and player velocity vector with respect to the physical point reflected are not generally parallel.
Please use baked reflection probes, for now.
I think I got frustrated with tutorial resources on specular reflections, earlier, and used some ad hoc idea of index of refraction that isn't right. Next step is to fix this, and to expand the specular reflection capabilities of the shader generally.