Raymarching Beginners' Thread
category: code [glöplog]
16k is too big. 8k is nice.
But please don't abuse this thread for discussing that :)
But please don't abuse this thread for discussing that :)
64k is fine, youre just all a bunch of pussies
<3
smash has the lead.
64M is fine, youre just all a bunch of pussies
a cat is fine too
Yes. Let's all squeeze our demos into cats. I'm with unc!!
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.
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 :)
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 :)
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
Mewler: Pre-calculate a wrapping version of the Perlin noise function?
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...
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...
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'.
las: that would certainly be cool, I've been wondering how that was done :) (my guess: feedback in a 3d texture, then raymarch that).
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
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
Would it not be easier to add something like that in post, unless really you want it animated / volumetric?
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:
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:
Las, correct me if I'm wrong :-)totalnoise = noise( pos+(time*a,0,0) + noise(pos+(time*b,0,0)) );
distanceValue += totalnoise;
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)..
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?
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);
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.
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.
+ increase by opaqueness itself - ie. similar to importance sampling.
(full) code or it didn't happen ;)
Nope the fixed stepsize thing isn't working for me. Just halfs my framerate and adds tons of banding, even with the noise.
las: maybe more like 'stepSize = (1+noise())*defaultStepSize' but apart from that, what iq and psycho said.. ;)