gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Voxel questions

#23140 - poslundc - Mon Jul 05, 2004 1:51 pm

Hey all,

I'm toying with the notion of doing some stuff with voxel landscapes as a bit of a side-project. I've been reading up on them, both in the forum and out on the net, and I want to write a voxel raycaster but there are a few things I am unsure of.

- Since unlike a traditional raycaster you can't just check along the map's gridlines, how do you determine the step size you use when casting a ray? Is it just trial and error to see what looks good?

- Assume no texture mapping for the moment, just simple flat shading. Once I've obtained the height of a span, would I just adjust the brightness of the terrain colour so that it is lit according to its distance, and then print the column?

- Now assume texture mapping. If I determine that there is a visible span, should I just check to see what texel would appear at that x/y coordinate, light it according to distance, and smear that texel for the entire length of the span?

Thanks,

Dan.

#23144 - DekuTree64 - Mon Jul 05, 2004 6:58 pm

I've never done a full voxel engine, but I did fiddle around and get one looking somewhat like ground in grayscale once.

From what I've read, you do just trial and error the step size. What seems to work best is to increase the step size as you get farther out, so you get plenty of accuracy up close, but don't take too much processing power. You can jump over entire hills in the distance if you make it too big though. Might be possible to mip-map your ground so this doesn't happen.

For lighting, I was going according to height, and doing a gradient down the column. That way hills get bright up top so you can see where they are better. You could probably do some kind of bump map-like shading depending on the slope of the hill to look even better. I think you'd still need to fade darker as you go down though, so valleys are less bright than hills, unless you have a lot of low and high flat spaces where it would seem right for the light to be the same on either one, since there's nothing around blocking it.
Making things brighter depending on distance may turn out to look good too though, or maybe on top of whatever other shading you use, as a fog effect.

Never got as far as texturing, but yeah, I think you just smear down the whole column. Still use whatever shading method you had before though, just use the texture as the base color.
I think the Lollipoop demo in the first GBADev compo used pure texture color though, and just painted the shadows on by hand. That might be the best solution of all, because it's fast, and gives you more control over exactly where the light and dark places are. You could still add fog though.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#23364 - krozen - Sat Jul 10, 2004 8:42 pm

i have done some work on voxels on the gba. the best program i find for the generation of height maps in one called "wilbur". Allows you to vary the elevation of the sun, produces height maps, light maps...everything!

#23369 - poslundc - Sun Jul 11, 2004 3:13 am

My voxel terrains would actually be generated by the GBA, not an external source. In any case, I think I'm abandoning the project anyway as it would take up too much time to complete.

Dan.