pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
And I just realised, there's a difference between occlusion and ambient occlusion. What I'm trying to do is straight occlusion rather than AO. Maybe O will be enough, maybe O + AO will look best.

Is lighting generally done with point or directional lights btw? Or a mix? (One light with shadows plus a bunch of directional lights should be trivial enough!)
added on the 2011-02-15 15:25:20 by psonice psonice
you can do the light however you want - the only limitation you have is speed.
added on the 2011-02-15 16:03:27 by las las
Speed isn't a problem, just lower the resolution even more ;)
added on the 2011-02-15 16:19:06 by psonice psonice
This seems very awesome. Is there an article which can get a complete newcomer into this kinda stuff? :)
added on the 2011-02-16 13:55:13 by nakedman nakedman
Am I the only one that have a feeling that we'll see a lot of cut-out-objects in future intros/demos in 2011? ;-)
added on the 2011-02-16 13:59:52 by Punqtured Punqtured
nakedman: Search for the raymarching toolbox thread on the pouet bbs

Punqtured: Might happen - more people working on it - more ideas - more progress - more fun.
added on the 2011-02-16 14:21:31 by las las
nakedman: http://www.pouet.net/topic.php?which=7931 should cover most of it. There's a raymarching loop at the bottom of las' first post, you need to provide it with a camera position and ray direction, and a function (try a simple sphere function initially to check if it works - also on that page).

Punqtured: expect a ton of wobbly blobs too ;)
added on the 2011-02-16 14:24:03 by psonice psonice
I just think this is great, using Pouet for something useful, sharing knowledge and educating people about how to do raymarching effects!
added on the 2011-02-16 23:48:05 by ekoli ekoli
Quick, someone post a cat or porn or anything unrelated!
added on the 2011-02-16 23:52:41 by msqrt msqrt
No powly - we don't need another residue thread here :)
Btw. I tried to fake something like colorbleeding - more or less successful. It was very hard to control and looked like crap - but I guess one can fake it better.

How do you handle color/materials in a fast way? I implemented my distance function twice, one version computes distance only the second version computes the material. (could be crunched by using macros).
Code: vec3 color; float nd, d; nd = d = dot(p-vec3(0.0,-1.0,0.0),vec3(0.0,1.0,0.0)); color = hsv(0.0, 1.0, 1.0); nd = dot(p-vec3(0.0,1.0,0.0),vec3(0.0,-1.0,0.0)); d = min(d, nd); color = mix(color, hsv(0.1, 1.0, 1.0), step(nd, d)); nd = dot(p-vec3(-1.0,0.0,0.0),vec3(1.0,0.0,0.0)); d = min(d, nd); color = mix(color, hsv(0.2, 0.6, 0.8), step(nd, d)); nd = dot(p-vec3(1.0,0.0,0.0),vec3(-1.0,0.0,0.0)); d = min(d, nd); color = mix(color, hsv(0.3, 0.0, 1.0), step(nd, d));

The version to determine the material is only used one time for each pixel, the distance only version far more often.

Another thing I thought of was encoding the material in the last 3 bits (8 different materials possible) of the float and let the min do the "branching" - this could be done by using asfloat and asint (the GLSL names are just too long). Maybe there's a more clever way to "watermark" the floats with the corresponding material - any ideas?
added on the 2011-02-17 00:33:58 by las las
float2
added on the 2011-02-17 05:12:14 by unc unc
or struct.
added on the 2011-02-17 07:24:57 by pommak pommak
punqtured, csg has evolved alot from the basic opengl-way using stencils - http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node11.ht ml
BB Image

The quest for decent shadows goes on.. and at last something that looks half decent. I'm using 20 iterations for the shadows, so the speed hit shouldn't be too harsh. I'll clean up the code at lunch time and post it in the toolbox thread, time to get ready for work now.
added on the 2011-02-17 08:40:53 by psonice psonice
Quote:

float2

But min is component wise... what one needs is a min that moves also the y component according to x values. Where is the point of using a float2 or struct?
added on the 2011-02-17 10:43:41 by las las
Code: float2 min2(float2 a,float2 b){return a.x<b.x?a:b;}
added on the 2011-02-17 10:48:11 by unc unc
I guess that will be way slower than using two separate versions of the field.
added on the 2011-02-17 10:59:36 by las las
i dunno, never used it :P
added on the 2011-02-17 11:06:52 by unc unc
Damn, I've been wondering all morning what the hell a float2 is! 64bit float? Some kind of new version of a float?! But it's just a vec2. Doh!

Unc: handy. Time to add some colours + materials :) Thanks.

Related question: Say we use the y component to determine if the material should have SSS, but we also want AO (or whatever other lighting.. and I wonder now wtf my shadow code does if I change it to SSS).

Switching between AO and SSS is pretty trivial, with something like

Code:l = ao(p, n, d * (dist > 0. ? 1. : -1.), float i)


But what's the best way to switch between AO and SSS+AO?
added on the 2011-02-17 11:10:38 by psonice psonice
oh, thought hit me right after I hit submit.

How about changing the AO function itself. For positive d, the ray steps out along the normal. For negative d, it alternates between +/- distance along the normal, so it calculates both AO and SSS in one step (but with half accuracy).
added on the 2011-02-17 11:13:16 by psonice psonice
You can do that. But I use very different step-widths for ao and sss also the number of samples differs.
You have to play around a lot to archive a good looking sss - maybe it's a good idea to try to combine it when you are almost done.

I would just compute both ao and sss as usual and then combine it on demand.
added on the 2011-02-17 11:38:52 by las las
Ahh and please use the sign function ;)
Code: l = ao(p, n, d * sign(dist), float i)
added on the 2011-02-17 11:41:45 by las las
Hmm.. I guess it's possible with a single AO function + some trickery, but more difficult. And good point about sign(), I have a bad habit of using conditionals all over the place where something else would be better.
added on the 2011-02-17 12:05:30 by psonice psonice
I would do that kind of trickery at the end of the development process because it really limits your choices and kills playing around with single values without side effects. btw. Nice shadows you've go there ;)

We really need more stuff on domain repetition in the toolbox thread. e.g. with polar coordinates you can repeat an object around an axis.
added on the 2011-02-17 13:16:51 by las las
@unc: if you're interested in participating in some pretty interesting vvvv developments, contact me (username m4d) or dottore on vvvv.org.. ;)
added on the 2011-02-17 23:51:47 by madMixx madMixx

login

Go to top