voxel / ideas

issue tracker for new voxel.js plugin ideas
4 stars 1 forks source link

Light levels #31

Open deathcap opened 10 years ago

deathcap commented 10 years ago

Propagate sunlight to each voxel, so that enclosed areas are dark, voxels exposed to the sky are bright, etc. This light level could be used for various gameplay features: spawning enemies in darkness, growing plants in light, and so on.

The most difficult issue with light levels may be handling voxel.js's "cubic chunks", where the Y dimension is as unbounded as X and Z. Some interesting discussion on the problems with lighting in cubic chunks and how they were solved in Minecraft modifications adding cubic chunks in: https://pay.reddit.com/r/Minecraft/comments/27ibll/mogminer_infinity_years_until_cubic_chunks/ http://redditlog.com/snapshots/736825 https://bitbucket.org/cuchaz/cubic-chunks

deathcap commented 8 years ago

Note these lighting-related modules exist:

https://github.com/deathcap/voxel-daylight simple configurable daytime lighting https://github.com/shama/voxel-sky :game_die::full_moon::sunny: A sky for voxel.js. Includes a sun, moon and stars.

but they are for the three.js-based voxel-engine (not compatible with voxel-engine-stackgl), and both only affect global ambient lighting - not localized lighting as would be affected by light levels

Some discussion of lighting algorithms: https://www.reddit.com/r/VoxelGameDev/comments/3yyxee/so_i_picked_up_my_voxel_engine_project_after/ - "A block is a light source and I do BFT [Breadth First Traversal, also called Breadth First Serch (BFS) ] to propagate light. The fragment shader then makes the texture darker depending on the light level of the facing air block."