pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
16k is too big. 8k is nice.
But please don't abuse this thread for discussing that :)
added on the 2011-05-18 17:49:17 by las las
64k is fine, youre just all a bunch of pussies
added on the 2011-05-18 17:51:31 by smash smash
<3
added on the 2011-05-18 18:32:56 by ferris ferris
smash has the lead.
added on the 2011-05-18 20:13:32 by xernobyl xernobyl
64M is fine, youre just all a bunch of pussies
a cat is fine too
added on the 2011-05-18 20:26:49 by unc unc
Yes. Let's all squeeze our demos into cats. I'm with unc!!
added on the 2011-05-18 20:38:22 by ferris ferris
Any Idea how to raymarch clouds, or fog? I did it with perlin noise once, but its VERY expensive, but looks awesome. Really needing it for an effect.
added on the 2011-05-20 06:34:42 by Mewler Mewler
i'd say raymarching them would be expensive, but using a fixed step size and just checking if a point is inside/outside the cloud might not be. You could just sum the points inside the clouds.

Hmm.. or maybe that would look quite badly aliased without lots of steps? Maybe use the distance function + fixed step size. Plus a bounding box to optimise out all the unnecessary steps. It won't integrate nicely with the raymarch though.

Another possibility: include the clouds in your regular raymarch, but separate them from the actual distance function. I.e. you have a separate float where you accumulate the cloud/fog value during the march. This way you can integrate them with the rest of the scene, and at the end of the march you get a distance and a value for the fog, but the fog doesn't affect the march step.

The clouds would get less accurate in empty spaces though, which could look strange. And you'd have to account for the step size when accumulating the fog value, or you'd get lots of fog around edges :)
added on the 2011-05-20 10:30:06 by psonice psonice
Thanks Psonice, but I've forgotten how I made the clouds :(. Something with perlin noise. I've got a screenshot but, I've totally forgot how I did it. I think it was a glitch :3
added on the 2011-05-20 11:13:05 by Mewler Mewler
Mewler: Pre-calculate a wrapping version of the Perlin noise function?
added on the 2011-05-20 11:14:22 by kusma kusma
I'd say raymarch normally, but without the clouds. Then raytrace, but only the clouds, just to know the distance the ray has gone into (or through) the clouds and use this to change the resulting colour. This is for uniformly colourd clouds/fog, but I think it could be easily modified for perlin clouds or whatever...

Anyway I didn't try this, just thought of it right now, so I have no idea of the performance you would get with this method...
added on the 2011-05-20 11:18:00 by flure flure
I'll post some stuff on raymarching clouds later this weeking, chock was so nice to explain me the technique of 'my code is my pr0n'.
added on the 2011-05-20 12:47:34 by las las
las: that would certainly be cool, I've been wondering how that was done :) (my guess: feedback in a 3d texture, then raymarch that).
added on the 2011-05-20 12:49:36 by psonice psonice
Thanks for the help! Kinda got it. Doesn't look much like a cloud and runs at like 8 fps :(

This is it now:
http://dl.dropbox.com/u/17070747/Betray.exe%203%20.bmp

The clouds floating around here are how I want it to end up: http://hiryu.deadendthrills.com/wp-content/gallery/the-void/game-2010-08-14-04-00-54-49.jpg
added on the 2011-05-20 13:02:32 by Mewler Mewler
Would it not be easier to add something like that in post, unless really you want it animated / volumetric?
added on the 2011-05-20 13:20:01 by psonice psonice
las: It's called 'code is my pron', it doesn't have to be my own :-)

psonice: Raymarching yes, but there is no feedback. I use 3D perlin noise 2 times where I move along the same dimension at different speeds. If I remember correctly, it is:
Code:totalnoise = noise( pos+(time*a,0,0) + noise(pos+(time*b,0,0)) ); distanceValue += totalnoise;
Las, correct me if I'm wrong :-)
added on the 2011-05-20 14:25:55 by chock chock
a simple hint for ray marching volumes: use a fixed step size, but to avoid banding, add a random sample onto the -first- step size to avoid banding, i.e. overall you'll have to have less samples/larger step size due to this (as the banding will be hidden in noise)..
added on the 2011-05-20 14:42:23 by toxie toxie
Chock: ah right! It looks quite like some 2d feedback effects, but done in a 3d. Interesting stuff. Hmm.. maybe it's time to see what can be done with 3d feedback?
added on the 2011-05-20 14:50:37 by psonice psonice
Quote:

a simple hint for ray marching volumes: use a fixed step size, but to avoid banding, add a random sample onto the -first- step size to avoid banding, i.e. overall you'll have to have less samples/larger step size due to this (as the banding will be hidden in noise)..


Hallo Dr. Toxie! :) So you mean something like the following?
Code: // Randomize frist stepsize in order to avoid banding stepSize = defaultStepSize + noise() * noiseFactor; do { // Do something with the position p [...] // Step foward (p = position, d = ray direction) p += d * stepSize; stepSize = defaultStepSize; } while (condition);
added on the 2011-05-20 15:46:40 by las las
las, exactly.

also, can also increase slightly you stepsize in the distance (proportionally to it), where features are small in camera, and the accumulated volume is already pretty opaque.
added on the 2011-05-20 18:58:09 by iq iq
+ increase by opaqueness itself - ie. similar to importance sampling.
added on the 2011-05-20 19:55:48 by Psycho Psycho
(full) code or it didn't happen ;)
added on the 2011-05-20 22:19:48 by xernobyl xernobyl
Nope the fixed stepsize thing isn't working for me. Just halfs my framerate and adds tons of banding, even with the noise.
added on the 2011-05-21 09:03:57 by Mewler Mewler
las: maybe more like 'stepSize = (1+noise())*defaultStepSize' but apart from that, what iq and psycho said.. ;)
added on the 2011-05-21 09:22:21 by toxie toxie

login

Go to top