pouët.net

Raymarching L-Systems

category: gfx [glöplog]
Rez: what flure said. It takes some time to "get it" initially (or it did for me at least.. plotting the intersection of a sphere with the scene along the path of a ray? Huh, what?) But once you get it (and it seems incredibly hard at first, but it really isn't) you'll find it is indeed quite easy. I'd say remembering all the opengl crap to set up a scene and render it is harder.
added on the 2011-05-09 10:40:37 by psonice psonice
I find it more intuitive to think of the marching functions return value as the maximum distance you can travel in any direction without hitting the object(s) instead of some magical sphere moving around and changing its size.

But I think I'll try marching some fractals now :)
added on the 2011-05-09 22:54:26 by msqrt msqrt
@msqrt: that is indeed a much easier concept to get the idea with, at least it was for me. i think all this 'sphere marching' was kind of a scientific approach. i work in research at the moment, and most of the time it's really simple and intuitive conecpts wrapped up in unnecessary complex fornulae.
i do find myself suspecting that scientists try to look smarter than they really are quite often. but then again, it's just another type of language, and one can argue that it is much more precise...
added on the 2011-05-10 09:21:52 by hcdlt hcdlt
I think the 'sphere tracing' concept makes complete sense.. but only after you understand the basic concepts of ray marching. Then it's kind of obvious. But to begin with, yeah, it's quite baffling when terms like that are used. Here's a (hopefully) simple explanation of what it is:

You render the scene by tracing a ray, starting at the camera, and moving in steps out into the scene until it hits an object. Now, the length of each step is critical - each step is quite expensive so we want the minimum number of them. Short steps are accurate, but we need many of them, long steps are more efficient but we don't want to step past any objects.

So what we do, is find out how far each point on the ray is from the nearest object. This is where 'distance fields' come in. It's quite simple, we just have a formula that tells us the distance from a point to an object. If we have many objects, we get the distance from each, then take the minimum.

If we know the distance from the closest object, we know it's safe to march to the next point on the ray, and we can march by that distance and guarantee we won't go past anything.

That's basically it, it's just a way of knowing how fast you can move along that ray without missing stuff, so it's efficient. When we hit something (or get close enough to call it a hit, that helps with speed) we get the normal at that point (just by taking the distance to the object, from a few points around the collision point), add light and materials, and that's the pixel rendered.

And what is the 'sphere tracing' part? When we get the distance from the closest object, it's that. That distance is the intersection of a sphere, with the centre on the current position, and the scene. And the sphere is the space we can move the point in, without risking missing an object.
added on the 2011-05-10 10:07:53 by psonice psonice
Just image the distance function f(x,y,z) as the radius of a protecting sphere around any point [x,y,z] the function f is defined for. You can move inside this sphere without hitting anything.
Come on, the "Sphere tracing" concept is not that damn abstract as you all pretend.
added on the 2011-05-10 10:42:34 by las las
It's not, but for me at least it made raymarching seem way more complex than it really is. Once I 'got it', yeah, it's a quite simple concept :)
added on the 2011-05-10 10:47:33 by psonice psonice
yeah, it's quite an easy concept to begin with, also far from being too abstract. I was referring to (mathmatics based) science in general.

Quote:
Now, the length of each step is critical - each step is quite expensive so we want the minimum number of them

I think you meant that the overall number of steps is expensive, because a single step is quite cheap actually.
added on the 2011-05-10 11:17:56 by hcdlt hcdlt
it's the same thing - longer steps = fewer steps, and a cheap step is still expensive when there's many of them :)
added on the 2011-05-10 11:22:01 by psonice psonice
I agree with that, but you said
Quote:
each step is quite expensive
and that was misleading, at least to me. also, i'm quite excessively splitting hairs today ;-)
added on the 2011-05-10 11:29:17 by hcdlt hcdlt
well, maybe we should say each step *should* be cheap if you want to use many of them (I know I've done some stuff with quite expensive steps, and it hurts :D)
added on the 2011-05-10 11:36:00 by psonice psonice
...this could develop into a german law text if we're going on like this :D
added on the 2011-05-10 11:37:23 by hcdlt hcdlt
haha, 'how to raymarch', written by a lawyer :D
added on the 2011-05-10 11:50:56 by psonice psonice
That pic is awesome IQ. I've looked up IFS, seen the article on your site but I cant get my head round how to raymarch them. Any ideas?
added on the 2011-05-13 07:25:24 by Mewler Mewler
Still stuck on this :(
added on the 2011-05-19 10:09:57 by Mewler Mewler

login