This video is sponsored by atlas vpn check out the first link in the description to get their 139 a month for three years deal Okay after the intro you might be thinking why am i even subscribed to this guy sully does make minecraft every couple years in between building computers and well it may look like that yeah if you take a look at my channel but actually this minecraft project is a one-off engine tester i’m actually Getting started on a longer term game to a project and thought this could be a fun way to get a 3d engine up and running so also though if you remember back to my first video where i said so i’ve seen a few other people around youtube making Minecraft clones but they all use shortcuts like 3d engines or languages with classes and garbage collection and namespaces and things you don’t really need well let’s be honest two years is a long time and i’ve learned a lot and grown a bit a man’s mind can expand and his audio Quality can improve in that sort of time and even though i’m still not the biggest fan of oop everything looking at you java i think it might be around time to give a language with classes a try that is c plus plus of course i’m not touching anything like c sharp With a 10 foot pole now a lot of you might ask why write a game in engine in c plus if there are all these other languages that you might like you might say c plus plus is old weird hard to debug non-memory safe he uses exceptions it’s bloated and while i Agree to some degree with you on all of those criticisms i think maybe that question is better for aces why not all those other languages and i mean i could make 10 whole videos about a list of all the other things that i didn’t like about these languages Their pros and cons and you know really turn up the flame more heat in the comments but to be honest cbs plus just beat out all the other languages on maturity and ease of adoption even though i’d never implemented anything more than a trivial project in It it should be easy enough to move from c once i’d worked through all the unique quirks and gotchas and then it will be smooth sailing after that right but anyway feel free to comment and flame me about how i should have picked your favorite language and tell me why I’m a huge big dumb idiot who should never be allowed near a keyboard because i picked c plus plus i guess uh flame wars will boost engagement anyway so once i picked out the language i started from this bjfx cube’s example and you’re probably wondering now hey i Haven’t really heard of bjfx where is that in the pantheon of directx opengl vulkan metal in france well bgfx is a really nice graphics library that actually sits on top of other graphics apis in order to have code that targets bjfx run on any number of different platforms with ideally Minimal changes it’s got a few quirks of its own of course but it’s been used in a lot of major games so i think it was good enough for me so finally let’s dive into the code skipping over the boring boilerplate of getting the cube’s example set up like Getting a window to show up communicating with input devices and stuff well this thing starts off a lot like my previous video first we make a cube then we make a lot of cubes then we make the cube’s natural faces which the camera can’t see Then we turn a lot of cubes into a lot lot of cubes using some chunking and this wasn’t all uninteresting but if you want to know more about the specifics here just check out my first video this stuff was basically the same but with more fighting c plus plus and Getting used to things like templates and finney uh uh substitution failure is not an error whatever that stuff is you can say it took me a few days to get used to programming in c plus but once i ended up getting used to it i actually ended up really liking Programming in c plus coming from c of course having namespaces was super nice and not having to throw sketchy macros in everywhere was pretty cool too and the whole thing just feels a little safer also the last time i tried c plus plus was in 2012 when c plus 11 was the Most recent version of the language and i can remember really missing optional types variants easier ways to write templates among other things which are all things that the language has gained since c plus 14 17 and 20. so it’s pretty nice to use now i gotta say even If some compilers are missing some of the more recent features and yes commenter before you comment i know that i’m deceiving my words from two years ago but got me some slack i guess people change now you’ve been able to see in the background here that engine programming Was kind of just chugging along so i was also able to port over the movement code for my old engine really really easily after a few mess-ups but here’s where things get different and the whole reason why i’m writing a new 3d edges for myself deferred Rendering that is the solution to how do i do a bunch of fancy effects in lighting on a big scene without setting my computer on fire but before we get to the deferred renderer i want to say a quick few words about the sponsor of this video atlas Vpn now as an avid internet user i’m always trying to find the best ways to protect my browsing when i’m surfing around the most recent addition to my arsenal security and speed is atlas vpn which is a special deal right now for a three year plan for just 1.39 cents a Month with atlas v you can enjoy blazing fast speeds while protecting an unlimited number of devices from ads and malware and of course most important of all you can enjoy netflix from wherever in the world you want for me of course since i grew up in the us and now live Over in europe i’m hopping on atlas vpn all the time to catch up on shows and movies that my friends in the us are talking about but i can’t get to over here in europe and for all of you over in the us you can always check out canada’s netflix library which includes Things like the harry potter movies the avengers and lord of the rings so if all that sounds like a pretty sweet deal to you be sure to check out the first link in the description to get the 1.39 a month for 3 years deal while it still lasts thanks to atlas vpns for Sponsoring this video and supporting the channel now to get down to the real business of this whole engine remake thing deferred rendering to explain exactly what this is i’ll bust out the pen and paper to explain how it differs from traditional forward rendering in regular 3d graphics rendering imagine this situation we have Two objects a and b and one light source from the camera’s perspective one of these objects b occludes object a but when we render we render a first and b second all of the pixels of object a which are eventually overlapped by object b just had a bunch of expensive Lighting calculations done for them which just got thrown away when we drew b in the deferred renderer though we wait to do the lighting calculations until we figured out only what pixels the camera is actually seeing so we render a and b in whatever order we want but we only Like the pixel switcher scene that’s kind of the gist of it but if you want to know more check out this article by learnopengl.com where a lot of my own implementation of this came from So here are the basics of how that’s implemented in the engine first we take our traditional scene here and we draw it into three buffers the depth buffer showing how far away each pixel is the color buffer showing the color of each pixel and the normal buffer storing Surface normals for each pixel now of course we can just render out the color buffer here and see our scene as it was but we want something better shadows from the sun for a little crash course on how real time shadows work from directional light and 3d graphics let’s draw this out as Well over here we’ve got our sun and then some cube and then some pixel behind the cube we’re rendering the pixel behind the cube and we want to find out if it’s shadow or not to determine if well it should be dark well to do this we first Need to find out what the sun can see that is render the scene from the sun’s perspective so we have a depth buffer from the sun’s point of view then when we’re doing the lighting calculations from this pixel and we want to find out how light or dark it is we Just take the pixel in the space of the world transform it into the sun’s perspective using some fancy matrices that i’m not going to explain in this video and then ask if it’s further away from the sun or has a higher depth value than the pixel which the sun can already See there if so then it’s in shadow i know this might be a little confusing if you’ve never heard about the technique before so again check out this learnopengl.com article if you want a better explanation anyway though once we have that stuff implemented in the engine and after a Few strange bugs are worked around we have sun shadows i also implemented a basic technique called pcf to make them look a little nicer around the edges after this it was time to go all in on some fancy deferred rendering effects not all of which i have the time to Describe here but basically in addition to the shadows i had an ambient occlusion again check out the learn opengl.com article for this if you want to know more specular lighting and a bloom for when that specular providing gets really intense and so how does our final scene look Well let’s look through the layers of the deferred renderer so first thing we do is we render the world into its basic color normal and depth buffers from the camera’s perspective then we draw the world from the sun’s perspective just under the depth buffer then we calculate the lighting for each Pixel then we calculate the screen space ambient occlusion for each pixel then we blur the bloom and ambient occlusion buffers and composite the entire scene together simple enough and all possible due to deferred shading So now back to minecraft the rest of the engine was actually pretty simple from here on out i just imported the textures that i had from my previous minecraft project and added a bunch of different block types defined by a few unique properties in the pre-existing tile code that i had And i gotta say things do look like they definitely got an upgrade from my old minecraft clone just through adding these basic blocks in the shadows in ao really do a lot so with that it was time to do the last little bit of this engine tester and implement infinite worlds Which are basically just done by tracking the player and making sure that chunks get loaded and unloaded and destroyed at the right times to make sure that there are always enough chunks around the player then it could go on to port the old world gen from my previous engine into the current engine It’s got a minecraft classic ish sort of look and i really like the way it turns out and after getting the basic terrain in i had worlds generating with trees oceans and all pretty speedy as well thank you to slapping the o2 flag on my c plus compiler The final thing i wanted to add to wrap up all of my graphical enhancements was a nice water shader the basic idea here is to use fractional brownie in motion with some noise to give smooth normal offsets in the water surface this is actually the same sort of basic Technique that’s used in the octave noise in the world generator this was already easy enough since i already had the water drawing with a separate shader as i’d moved it into a separate mesh from the rest of the world earlier in the development process and if we check out the code here you Can see that the fractional brownian motion part is a little arcane but the key here are these normal offsets being given by the water height map at any given time this code was however adapted from a really nice raycasting water shader on shader toy if you want to go check out The original the link is in the description and with all that work this is what our new water looks like not too bad for just a few lines of shader code i think now though it was time to recreate the original house for my very first youtube Video and call it for engine development for now Of course this minecraft won’t be here to stay this was basically just a big excuse to get some fancy 3d engine stuff up and running so expect more game dev videos more regularly and soon things can go a little faster now that i don’t have to implement all my ideas and hardware Check out the description for a link to all the code on github and for one last time be sure to check out atlasvpn as the first link in the description for a great deal on a fantastic vbn thanks as always for watching and i’ll see you next time probably with some more Gamedev programming You Video Information
This video, titled ‘I programmed Minecraft from scratch… again.’, was uploaded by jdh on 2022-01-15 15:46:49. It has garnered views and [vid_likes] likes. The duration of the video is or seconds.
Grab Atlas VPN for just $1.39/mo before the deal expires: https://atlasv.pn/jdh come back next week im making minecraft …