Sign in to follow this  
Magogan

Lighting and what else for a good-looking voxel game?

Recommended Posts

Hi,

 

3 questions:

 

First: Is there a best approach on how to implement lighting in a voxel engine? I already have a directional light and shadows, but the brightness of the shadow is the same everythere... I thought about storing a "light level" for each voxel in a texture and compute how dark a shadow is in a post-processing shader (per pixel), so I could not just determine the darkness of the shadows on the voxels, but also of the shadows on characters and objects. Should I do this for lit areas (which are determined by the shadow mapping) or should I just take the diffuse directional lighting intensity plus the intensity of point lights for lit areas?

 

Second: Are there any other things I could do to improve the look of a voxel game? It is not easy to navigate in caves because everything looks similar, even with textures... I don't know how to describe this... you sometimes can hardly see the edges of a voxel...

 

Third: How can I achieve that if you look from outside into a cave, everything is really dark, but when you walk into that cave, your eyes get used to the darkness and everything seems a little bit brighter (and vice versa when you leave the cave)? Should I just use the light intensity at the camera position for this?

 

Screenshot (4.07 MiB)

Edited by Magogan

Share this post


Link to post
Share on other sites

For outside: atmospheric fog - the greater the distance, the lighter the colors and the lower the contrast from light to dark. Even linear fog will enhance the feeling of distance.

 

For both inside and outside: mipmapping - more texture detail (maybe even normal mapping) for close objects. That will help to define edges a little better.

 

For reflective surfaces: specular lighting, particularly for water.

 

Lighting in caves: that can be problematic unless you can set a flag for surfaces that are inside a cave or hole. If you can do that, then for those surfaces, use a higher power for the diffuse intensity dropoff with distance - i.e., different lighting equations than outside. That will help darken voxels further from the eye and provide more contrast along edges. You could even code the power to be based on distance. I.e., the farther you are from a cave entrance, the more drastic the dropoff - to the point if you're more than several units away from the entrance, the light doesn't "penetrate."

 

I've not implemented it myself, so I'm unsure of the approach, but there is more color and contrast in shadow than in light. Not brightness, but color detail. Perhaps if you can use a paler-flatter texture for lighted pixels, and more colorful-higher contrast texture for shadowed pixels..

Edited by Buckeye

Share this post


Link to post
Share on other sites

Part of the issue is directional lighting. With purely directional lighting, every vertex, face and pixel receives the same intensity of light, depending on its orientation to the light source, resulting in a flat shaded look.

Share this post


Link to post
Share on other sites
The light level I mentioned is similar to the flag "inside/outside a cave", but with 8 bit for better transitions between areas with different brightness.

I already have mipmapping, but I want the world to look more "pixelistic" (something like minecraft, but with 32x32 textures on 0.5 meter voxels instead of 16x16 on 1 meter voxels).

Share this post


Link to post
Share on other sites

Directional lighting is generally not sufficient for attractive terrain. At the very least, you usually want to fake hemisphere lighting from the sky dome, and some sort of ambient lighting to simulate indirect bounce lighting from the surrounding terrain.
 
Inigo Quilez has an interesting article on faking terrain lighting. Also on terrain fog.

Share this post


Link to post
Share on other sites

I use some fake directional-based ambient lighting. This is what it looks like in my voxel engine. The idea came from this article on image-based ambient lighting but I kept it more simple and instead am just using the six sides of a cube to gather lighting.

 

It's a simplified version of what Swiftcoder posted. The sides facing the skydome have different tints of color which change during the day/night cycle, as well as the intensity of the light bounce (how much they contribute to the final color). The sides facing the bottom are less saturated versions of the top colors. I only did this because the voxel lighting will block most of the light from the bottom sides anyways.

Edited by CC Ricers

Share this post


Link to post
Share on other sites

With voxels it should be quite easy to make some sort of semi dynamic GI system.

For some easier enhancements I would add scrolling cloud shadows.(simple projective textures). This add large scale dynamic and spatial variance. I also use lower mipmaps from cloud textures for diffuse and specular skylight shadowing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this