Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Lighting Voxel Buildings With Per-Vertex Lighting

Lighting Voxel Buildings With Per-Vertex Lighting

VoxycDev
VoxycDev
VoxycDev · · 1 min read
2,923 0

I finally found a way to light voxel buildings with per-vertex lighting that looks decent. They key is to have a RGB values for each voxel, and set them in the following way:

  • Start from an empty point somewhere in the room
  • Expand on all three axes as far as you can until you hit a voxel on each axis, save min/max values
  • Fill a rectangle box bound by min/max values on the three axes with desired RGB values

This works relatively well if each corner of each voxel/quad takes the color of the voxel value to the left/lower/rear of it (on x, y and z correspondingly). Then when you go from a somewhat radical RGB value (1.0, 1.0, 1.4 in this case) to default 1.0, 1.0, 1.0 in the next voxel, you get a nice gradient due to interpolation in the shader. If bet it will look even nicer if I try to make a gradient in the RGB voxel values from top to bottom, as if the light comes from the lamps on the ceiling. Gotta try that next.

Discussion

Loading comments...