Adding infinite build height and colored lights to my Minecraft engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to my channel this is a relatively brief update video on the state of my minecraft clone which I made in two days after making some more substantial updates to the engine go check out my previous video if you haven't seen it since the lays the groundwork for most of this video so to jump right into the updates one of the first things the codebase desperately needed was refactoring and cleanup everywhere because I only spent two days on my initial engine a lot of the code was garbage like pure unapologetic garbage the refactor itself took a couple days until I was happy with the state of the codebase after that one of the first new features I wanted to tackle was removing the build height limit see minecraft is only actually infinite on the X and z axes but has a hard-coded 256 block height limit on the y-axis I removed this constraint by switching over to using cubic chunks which are 32 by 32 by 32 blocks and can stack infinitely on the y axis instead of minecraft like chunks which are 16 by 16 by 256 blocks and don't stack vertically here's one of my first working tests of those changes and once I worked out the bugs with the cubic chunks I hacked back in a really basic world generator and place some blocks to make sure that nothing was too broken [Music] everything looked good so I started on the real major update I wanted to make biting biting a minecraft works by giving every transparent block a light intensity value between 0 and 15 and having neighboring solid blocks to use this value to determine the brightness of their faces basic implementation required some minor tweaks to the rendering and meshing code and I got some good results really quickly once I had the graphics groundwork in for light intensity I moved on to propagation for someone realistic light attenuation of Minecraft uses a system where light propagates from one block to another by losing one unit of intensity with each block of distance from the original light source this quick animation gives a simple example of how that works [Music] if we only allow light to propagate through transparent blocks then we get some basic shading too this is easy enough to implement using some basic cues and looks pretty nice now once I had that done I wanted to do something minecraft can't collard biting as it turns out color binding is actually pretty simple instead of using only one value to represent the light intensity we can use for red green blue and intensity to mix colors around now each transparent block has four numbers from 0 to 15 determining its light color and instead of having block faces change color only according to brightness they use these RGB and intensity values as multiplies to their own colors and after a little tweaking this is working too when the effect looks really good to add sunlight in the game I added a data value for each block from 0 to 15 indicating a sunlight intensity similar to how the lighting was done sunlight is propagated in the same way as torchlight except it doesn't attenuate when going downwards so it express infinitely in the negative y-direction to mimic real sunlight [Music] the next edition my game needed was a sky and a sun which could look like it was lighting the world up to start I added in two colored planes above and below the camera I've called a sky plane and a void plane which would let me changed his sky color as I choose once that was working adding in a Sun and the moon as as simple as adding in more 2d planes which rotate around the camera as time passes in the game I also picked out some nice sunrise and sunset colors and added in color interpolation to make day and night transitions look smooth their stars were up next and these were a little more interesting stars were added by taking a small 2d star texture and rendering it hundreds of times with random position size color and twinkle or animation offsets all throughout the sky [Music] the stars then rotate around the player at a similar rate to the moon around a fixed axis this is of course not a physically accurate solar system simulation by any means but it ended up looking pretty good after that I quickly hacked in some 2d clouds as a solid plane at a fixed height in the world which moves with time finally i ported some of the old world generation code into the refactored code base so I can make sure that both lighting and the sky worked alright with everything next on my update list was physics something a lot of people pointed out my initial implementation was lacking I started by giving each block an axis aligned bounding box or AABB which defined a fixed 3d area for each block a a B B's are a dead simple way to implement collision detection for physics engines and lend themselves well the voxel games like Minecraft since blocks are never rotated around strange angles the key to an ax a BB is that its access aligned it can't be rotated this can limit functionality but it makes them really easy to use to start implementing these in the game code I gave the player an AABB and modified the camera movement code so that the player a BB and block a a B B's would never collide after that came some gravity which you can see me testing repeatedly here finding the right value took a lot of tweaking and finally some real movement code the way the player moves on and in each block is determined by a number of properties that can differ from block to block these are whether or not the block is solid of gravity multiplier drag and slipperiness water physics ended up taking a long time to get right and I'm still not totally satisfied with how they worked out but they ended up being workable I made a small hack to the physic system to where the players jump velocity is boosted if the player is trying to get out of the water so they can get on top of the solid block that boarders water this is stolen straight out of the Minecraft physics system the last big update I made was to the world generation again not totally satisfied on how to send it up but I worked out a three-part system for determining each pile where the biome for each area is determined by a random height map temperature map and moisture map all generated using Perlin noise these give a somewhat realistic representation of what real environments look like added in some biomes and unique blocks in Florida give each area a different feel to some of the new biomes for desert taiga savanna Tundra mountain and boy I also threw in pine trees to make taiga biomes different from other forests I also modified the block meshing system to allow for blocks to define their own mesh parameters this allows minecraft style torches which you can see here and got them to emit light too by adding a few new properties for each block which specify light color and intensity for light emitting blocks oh and I hacked in some dynamic moving lights just to flex on minecraft a little bit and finally a couple UI updates were in order Irie factored the code added in a classic minecraft style block picker and got to work on some building again to finish out the video [Music] and that's all for this update video thanks for watching and be sure to check out my last video about the initial design of my minecraft clone in case you missed it [Music]
Info
Channel: jdh
Views: 307,435
Rating: undefined out of 5
Keywords: c++, programming, coding, minecraft, opengl, graphics, java, voxel, 3d, gamedev, gaming, code
Id: NLbzPQoHkXI
Channel Id: undefined
Length: 9min 50sec (590 seconds)
Published: Thu Jun 04 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.