ray-tracer icon indicating copy to clipboard operation
ray-tracer copied to clipboard

Path tracing

Open w23 opened this issue 6 years ago • 5 comments

Pretty pictures easy (and slow. veeeeery slooooow)

w23 avatar Jul 31 '18 16:07 w23

@w23 isn't this a duplicate of #14?

rexim avatar Jul 31 '18 19:07 rexim

It depends on what you meant by Ray Tracing there ;). "Ray tracing" usually means just this: the geometry is rasterized using some form of ray-geometry intersection tests, as opposed to more common triangle rasterization, where you project each triangle onto screen at once and fill its pixels. It doesn't say anything about pixel colors, lighting, textures, etc.

There are several ways to do ray-intersection tests, for example:

  • analytical; this involves solving ray-sphere, ray-plane, ray-triangle, ray-whatever intersection equations manually on a piece of paper and implementing that. Advantages: each object is checked only once; solutions are precise. Disadvantages: you're limited to a set of a few well-known forms that have analytical solutions for ray intersections.
  • sphere/cone tracing implicit surfaces with distance fields (all cool demoscene kids do that); for each shape you have a really simple function that gives an estimate distance to this shape, and you march the ray by steps of this estimation until you're close enough (epsilon) to register a hit. Advantages: conceptually very simple; it's easy to get very complex shapes (easy: CSG, repetition/mirroring, domain deformations, etc.); geometry representation (distance fields) can be reused to do effects like ambient occlusion and soft shadows. Disadvantages: not very precise (performance tradeoff), gives lots of artifacts, choose epsilon wisely; has annoying corner cases, e.g. marching a ray along flat plane and not hitting it is very fucking expensive; only allows for analytical geometry given in mathematical form, loading e.g. triangle models or anything else sculpted by hand would require building something similar to acceleration structures (e.g. 3d texture, octree, ...), very likely offline.

w23 avatar Aug 01 '18 10:08 w23

Path tracing is more about lighting. It's a method to calculate lighting and global illumination (a holy grail in computer graphics) by bouncing the ray around a lot. You can use any intersection test for it (although, in reality, i've only been able to do realtime path tracing for very simple scenes of a few analytical spheres and planes).

w23 avatar Aug 01 '18 10:08 w23

I'm in favor of this :D

saidm00 avatar Sep 03 '18 22:09 saidm00

Yeah ray marching or sphere tracing gets annoying when you offset a shape and get non exact distances. Also you have to handle overstepping when you optimize and a lot of other problems. The regular algorithm is slow, etc... Path traced analytic solution is the best imo for offline rendering. For realtime sphere tracing with simple lighting is much more flexible and performant. Check out Mirror Drop game ;).

saidm00 avatar Sep 03 '18 22:09 saidm00