GENERAL > Projects

Raymarching Beginners' Thread

<< < (2/7) > >>

rbz:
@combatking0: the basic concept is constructing a ray from your camera position into your scene, from that point you will be "marching" in steps until you hit a surface and then you can extract information from this surface like colors etc.

Btw, I've managed to add shadows and ambient occlusion, this code was kinda provided by las/mercury on here, I'll post an image and perhaps an .exe tomorrow :)


--- Code: ---//negative d -> sss, positive d -> ao
float ao(vec3 p, vec3 n, float d, float i) {
float o,s=sign(d);
for (o=s*.5+.5;i>0.;i--) {
o-=(i*d-f(p+n*i*d*s))/exp2(i);
}
return o;
}

// p pos, l direction to light - normalized, d stepwidth, i number of steps
float shadow(vec3 p, vec3 l, float d, float i) {
float o;
for (o = 0.; i > 0.; i--) {
o += f(p+l*i*d);
}
return clamp(o, 0.0, 1.0);
}

--- End code ---

Kirl:
Great stuff rbz, hope to get started as well someday, love the movie you posted!

CK, have a look at Cinema4d by Maxon. It's one of the more user friendly, fully featured 3d software packages around. I'm somewhat of an expert on it, so you can shoot me mail whenever you get stuck.

rain_storm:
K+ for rounding up this info, This is exactly what I've been needing for my voxel engine. I was planning on going down the Sparse Octree Voxel Traversal meathod but I really hated the idea of stepping forward finding a voxel that was full and backing up only to step forward by half the original step size. With this meathod the ray is constantly moving forward. You never have to take a step backwards and you still have a step size that will accellerate vast empty expanses spending more time in densely populated areas.

At the moment I am testing my voxel engine at a resolution of 640x480 in an environment of 256x256x256 so long as most of the visible voxels are close by I can even push the resolution up to 1024x768 with no obvious slow down, but once you enter into an open area its far too slow to even think of any resolution higher than 640x480.

Thanks for gathering all of this info into one post.

Edit - Hehehe It worked like a dream worth some extra karma to rbz
 Resolution=1024x768
 Environment=128x128x128
 Framerate is acceptable

rbz:
Well done Rain_storm, it works pretty well here on 1280x1024 res and I believe it's software rendered?

Here's an image with shadows added.

rain_storm:
Yup thats all software rendered. The best thing is:
rgba == 0, distance != 0 (empty voxels)
rgba != 0, distance == 0 (filled voxels)
looks like a marriage made in heaven

I've been playing around with the cube distance function from your first post. Its starting to look like a morphed square but still aint got anything 3D yet. Will keep at this.

Do you think it would be possible to model a SuperShape as a distance function? That would be awesome.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version