Lighting lighting is essential to making a good looking game as it is a core component of a game’s environment and art style last time we implemented video memory optimizations which means now we can focus on adding lighting to our Minecraft clone so let us cast this World into darkness to begin our work on my team first we must Implement block lights which are blocks that emit lights that reduce over a given distance like Minecraft we’ll choose a range of light values from 0 to 15. the lighting algorithm first scans through all the Blocks in a chunk if any of them are lights it adds them to a queue for the propagation phase if it is on the board of a chunk we’ll check the boarding blocks and if it has light value reduce it by one for the current block and add It to the lighting queue in the propagation phase which uses breadth first search go through each position in the queue and check all neighboring blocks if the neighboring block has a value less than the current value -1 then set it to the current value -1 and Add it to the Q if the neighboring block is solid then do not update the light value and do not add it to the queue repeat this process until the queue is empty note that lighting values can be overwritten by neighboring chunks when calculating for the respective lines to Calculate lighting from the sky we take the topmost chunk and set the topmost air blocks to a skylighting value of 15 and add it to its own Sky lighting queue just like before we take the values of neighboring blocks of adjacent chunks and add it to the queue as well the Propagation phase is exactly the same as before with one major difference if the current Sky lighting values 15 then when propagating to the air block below set the sky lighting value to 15 instead of subtracting 1. we can go one step further and introduce colored block Lights by storing a short that contains Three lighting values of 0 to 15 and using that for lighting calculations when propagating check each individual r g and B component rather than a single value and when setting the value for the current block get the maximum components between the neighboring value -1 and the current value the largest problem with Lighting is the memory usage especially with colored lights but we have a few tricks up Our Sleeve to optimize it remember in the first episode we had huge memory savings by storing blocks and layers where if the layer has all blocks of the same value it’s only represented by a single value rather Than a value for each block likewise we can do the same for both block lights and skylines in particular we know that opaque blocks will not need light values and stop slides from propagating by applying this we only store lighting by is when we need to meaning only the top Most layers have skylighting data and only layers within reach of block lights have data one last optimization that can be done is to store skylights which are values from 0 to 15 and nipples instead of bytes by sharing a bytes between two positions cutting the memory usage for Skylights in half with colored lights we store shorts for each block but we only need 12 bits out of each 16 bit short four bits are wasted here unfortunately where most implementations take advantage of this by storing Skylight values here however the advantage of separating out skylights in our layered Memory layout means that we don’t need to store full short values where there are no block lights meaning greater memory savings overall for the general case colored lights have a similar computational cost compared to monochrome lights with a likely worst case having lights with only one component maximized at around 15 blocks Away from each other having taken care of the memory colored lights are absolutely worth it due to the creativity enables for example imagine a fairy Force of green glowing in the night or volcanic orange or deep red Cavern or sci-fi laboratory with glowing blue terminals having accomplished this It’s now time to look at your comments why have you not uploaded in a while it’s difficult to juggle this large product alongside my full-time job my health issues and my friends who rely on my other projects real life can and will get in the way and it’s important to use Whatever free time you can get ideally I’d upload one video a week but I expect the next one to be quite the challenging one so expect another delay on Vulcan Vulcan is notoriously difficult and I’m putting it off for later for good reason assuming I make the switch at all But your responses did get me thinking more about drill calls and open jail and how they are actually multiple State switches followed by draw command and I think I discovered a way for massive speed up and rendering if it works out and I’ll tell you about it in my next Video on Textures I am using Minecraft’s textures for debugging purposes and strictly speaking you are watching Minecraft content despite being a separate program entirely but once the game has its own identity where I release it in some form I cannot use the textures or assets related to Minecraft Expect some programmer Arts after all the basics are done are you an AI with the advances of AI I think I’ll take this as a compliment I think the reason a lot of you think I sound like one is because I try to speak clearly and I cut Out the unnecessary breaths and pauses which ironically AI tries hard to mimic so I guess they might sound more real than I do lastly quite a few of you commented on World Generation LEDs and we’re quite excited for it I have a few ideas regarding algorithms I might use But we have a long way to go before touching that again and we need to get the foundations of the game right before adding features the next video will likely tackle custom block shapes directional blocks and block states which I’m dreading since it will be a massive overhaul of everything I’ve done So far but it is absolutely necessary for the game going forward so keep in mind the next video I expect to take a bit of time I suspect using the community tab will be of use here until the next video comes out although I’m not too familiar with it do you guys Want me to use it if so what should I put on there let me know in the comments in the meantime stay tuned take care and I’ll see you next time Video Information
This video, titled ‘I Remade Minecraft With Colored Lights’, was uploaded by FinalForEach on 2023-09-26 19:16:31. It has garnered 45803 views and 6461 likes. The duration of the video is 00:05:47 or 347 seconds.
In this devlog of remaking minecraft in java, I implement lighting and shadows, including coloured block lights.
Music used: Radiant Historia OST – Shadows Dance In The Darkness Radiant Historia OST – The Melody Connecting The World
Useful resources: LibGDX: https://libgdx.com/ Learn OpenGL: https://learnopengl.com/