How to make simple lighting?

Oct 23, 2011 at 10:50 AM

Hi everyone.

I want to delete smooth lighting, because I think it's the reason of low fps. In other games I have more fps.

Can you tell me how to make simple lighting like in Minecraft but during the alpha?

Something like this: http://static.accelerated-ideas.com/news/images/top_10_minecraft_mods.jpg

Like the shadow is going to be darkness on each block.

Sorry for bad English.

Help me please.

Oct 26, 2011 at 1:55 AM
Edited Oct 26, 2011 at 2:08 AM

If you go back to the earlier code - around this changeset i think http://techcraft.codeplex.com/SourceControl/changeset/changes/b27c7b631fb3 you should be able to see how to do standard lighting. You're right that the smooth lighting/ao is a big problem with the way this engine is implemented. The issue is that it is dependant on all the surrounding blocks and the way blocks and chunks are managed in this code makes that quite time consuming. This engine was initially developed from looking at the way infiniminer worked but that technique isn't really scalable for things like smooth lighting and ao.

The basic lighting works as follows - for each vertical row in a chunk propogate the light downwards from the sky setting the light value of each block to the sun maximun (16) until you hit the first solid block - then for each block in the chunk which has a non zero light value propogate the light outwards using a flood fill reducing the light value each step. This is all the same in the current code if you remove all the rgb light stuff. The main code you need to change is when building the cube face vertices instead of getting the light values from all the surrounding blocks simply use the light value from the block directly adjoining the face.

The main issue with FPS in this code though is that the chunk generation, lighting and game update all run on a single thread. To maintain a solid fps you would need to offload the generation and lighting onto another thread so it is done in the background. This is pretty much the main reason development on this code stalled - again the way the chunks are managed made that pretty much a nightmare to do - we tried all sorts of ways but never got something satisfactory which didn't have lighting 'glitches'. If you go back even a couple changesets from the current head revision you can see some of the various experiments that were tried, we removed the multithreading when we stopped working on this code in order to leave the project in a state that wasn't buggy.

Nov 8, 2011 at 9:45 PM

What was your reason for scrapping the deferred rendering?  Did you notice a performance hit?

Nov 23, 2011 at 4:00 PM

There is definately a peformance hit with deferred lighting since the scene is rendered 4 times, however the main reason was that i used Sunburn for the lighting and didn't want a dependancy for that in the open source version.