3 ms·
I'm confused- don't all ray tracers use snell's law or is there a different equation for reflection (https://en.wikipedia.org/wiki/Specular_reflection https://e
by dekhn 5y ago
I'm confused- don't all ray tracers use snell's law or is there a different equation for reflection (https://en.wikipedia.org/wiki/Specular_reflection https://en.wikipedia.org/wiki/Specular_reflection)?
Nearly everybody I've worked with who's implemented a ray tracer says there's only one thing that matters, and that's implementing the reflection equation (I mean for first order ray tracing, not interesting stuff).
As for asset loading, like I said, I think it's a solved problem. When I start Cyperpunk 2077 on my machine (fresh, no cache), it takes less than 30 seconds to get to a playable state and my SSD is basically streaming data into RAM as fast as it can.
- Sharlin 5y agoSnell's law is about refraction rather than reflection.
- kragen 5y agoYou ask, "Don't all ray tracers use snell's law or is there a different equation for reflection?" The answer is that, well, you can derive both Snell's law and Heron's law of reflection from Fermat's principle of least time (which you can derive from the wave equation), but Heron's law of specular reflection isn't usually considered to be a consequence of Snell's law; even when you're implementing TIR you can't just use the Snell's-law result because it's gone imaginary. If you only want diffuse reflection and shadows, which is a thing you could potentially use ray tracing for, you don't even need the specular-reflection law. This might be a sensible thing to do if, for example, you were rendering a 3-D IFS; using a raytracer with BVHs allows you to do this lazily and thus get immensely more detail than a rasterizer could do. (An alternative to conventional raytracing I've been thinking might be fun is to train a PINN on a scene with the wave equation --- a differentiable neural network which maps (x, y, z) tuples to "electromagnetic field" vectors or just pointwise amplitude and phase, trained using a loss that incorporates its deviation from the wave equation and the given boundary conditions. Then you can evaluate the amplitude of light at every pixel on an imaging plane behind a lens or pinhole camera, thus simulating bokeh, reflection, refraction, defocus, and potentially even diffraction and polarization effects. Then instead of explicitly programming Heron's reflection law, Snell's law, the Fresnel equations, etc., they'd just appear as emergent properties of the wave equation. May not work out in practice tho.) Perhaps if Cyperpunk 2077 were using a liability pipeline that was rethought with SSDs in mind, you wouldn't have to have all that data in your RAM at once; most of it could be left on the SSD until later, thus avoiding the 30-second delay. (As I suggested, SSDs are maybe two orders of magnitude higher bandwidth, but have nearly four orders of magnitude lower read latency.) This kind of thing is a bigger problem for open-world-type games like Minetest where the data volume is potentially unbounded because players add to it over time, and where the 30-second glitches can't be papered over with cutscenes and the like.
- dekhn 5y agoThanks for correcting me (https://en.wikipedia.org/wiki/Fermat%27s_principle https://en.wikipedia.org/wiki/Fermat%27s_principle). BTW, your parenthetical 3rd paragraph is a fairly deep question and fast approximations to it would be useful beyond just rendering scenes realistically. I assume you're familiar with the use of lenses to implement FTs long before they were computationally tractable (https://en.wikipedia.org/wiki/Fourier_optics https://en.wikipedia.org/wiki/Fourier_optics)?
- kragen 5y agoHappy to help! The PINN idea seems interesting but it may or may not work out; if you're interested in that kind of thing, there's more of it in Dercuano, Derctuo, and Dernocua. Some of the ideas in there have been tested and work, others have been tested and found not to work, but most are still untested. As for Fourier optics, yeah, I worked with a guy last millennium who had worked on some optical analog pattern recognition stuff at university. I've never gotten it to work myself; I suck at lab work so far.
- dekhn 5y agoI have also tried to set up Fourier optics and failed! I have friends who can, though. Trust me, stick with silicon for now.
- kmill 5y agoI don't know too much about it, other than that a symplectic geometer friend helped out, but light field networks seem interesting: https://www.vincentsitzmann.com/lfns/ https://www.vincentsitzmann.com/lfns/ Something I've thought would be interesting is simulating the entire light field by some kind of finite element analysis, but where each element uses a neural network to more quickly converge to the correct lightfield -- and, perhaps like that paper, to use neural networks to give a compact representation of the lightfield at that element. The stratospheric view of what a raytracer even is is a monte carlo sampler to evaluate a (fairly complicated) integral. It seems like many tricks for raytracing are about finding better ways to estimate good sampling distributions (for example, when scattering, a heuristic is to send more rays toward light sources). So, being able to simulate the light field more accurately and quicker could get the rendering integral to converge quicker, too. It sort of reminds me of game-playing AIs like AlphaGo. There's a tree search: the AI is playing a game where a ray is bouncing in a scene, and whenever the beam is scattering it gets to choose which direction to send it -- its goal is to collect light that gives close to the correct pixel color with the least number of beams.