four trillion blocks the amount of blocks currently perceptible with the naked human eye compatible with shaders and multiplayer with non-existent lag on my mid-range computer and it all begins in this brand new Unity project the block part of the block game was straightforward step one was manufacturing a script to summon millions of blocks for the terrain unfortunately the game part of the block game was hard this is literally unplayable due to the sheer quantity of objects the solution was copious optimization luckily I knew a guy who watched a guy who knew how to do [Music]
this instead of instantiating one object per block blocks are simply stored in an array of data this data is used to generate a single mesh which is a three-dimensional model made of vertices joining to multitudinous triangles less triangles means higher performance ments so the code adds for vertices only for faces that aren't obscured by solid blocks each vertex also incorporates its own information normals help create believable shading by specifying which direction the face is facing and UVS are coordinates specifying which area of a texture the face should use the completed mesh is then assigned to
a chunk object to be rendered the result is our first chunk but more discretionary faces could be extinguished with frustum culling faces beyond the field of view are disregarded further calling is accomplished by splitting the mesh into one piece per side so that any sides facing away from the camera are disabled but besides reducing the vertex count we could also optimize vertices themselves the default vertex consumes five thermodynamic and tropies of the sun of unused data these are eliminated by customizing the mesh even further and since this is a block game vertex positions tends to
be whole numbers meaning they can be stored as the smallest data type binds now I could effectuate hundreds of chunks without causing an FPS Singularity but instead of using Minecraft's chunk system I Incorporated cubic chunks meaning the world is infinitely explorable in all Dimensions therefore the height limit is non-existent but when I continuously spawned new chunks around the camera I was jump scared by copious lag spikes it appears that while chunk rendering was optimized chunk generation was abysmal so it was time to commence profiling this involves spamming stopwatches everywhere to time all operations to locate
the biggest time consumers but no matter what optimizations I used the lag spikes prevailed the limit now was the language itself C rust a memory save compile programming language that delivers High Lev simplicity shut up shut up C employs numerous hidden systems to ensure the program functions safely this causes overhead which is essentially lag from behind the scenes this could be solved by abusing the burst compiler burst creates highly efficient programs by disabling safety measures meaning more responsibility Falls onto the programmer and I was punished by iaso HEC millions of massive memory leaks and unexplainable
crashes I rewrote half of the entire project to satisfy the burst compiler overlords in return chunk generation and rendering became 10 times faster both were now imperceptible to the human eye but how does this perform on much higher scales the current render distance is four chunks the goal is to acquire the ordinary visibility on a clear day 8 km so instead of writing faster code I now needed smarter code rather than generate stuff faster I would generate less stuff small details such as singular blocks are practically invisible Beyond a certain distance therefore farther chunks could
get away with generating one block per 8 cubic Mets even farther chunks shall have progressively lower resolution eventually reaching the single block per chunk low detail chunks are then combined to reduce the total number of objects all of this was implemented but I was still unsatisfied we had to go even further with the fanciest optimization yet greedy meshing the idea is that adjacent squares can be combined into larger rectangles to reduce triangle count but the implementation was extreme demon difficulty most tutorials were massive y apocalypses discussing abstract math and theoretical theories I found actual code
on Reddit of all places which I used as inspiration for my own algorithm after a few unexplainable disasters and bizarre catastrophes the greedy measure was now functional by combining all optimizations so far I could finally exhibit stupendous quantities of terrain but while I had technically achieved my goal the sheer quantities of Chunk generation at the start of the game caused abysmal lag this is because all chunk generation runs on the main thread by default since frame updates also occur on the main thread the game freezes until all other operations are completed this this is single
threading and its consequences but by abusing unity's job system and C's task system chunk generation was banished to a different thread while the results were sent back later to be rendered the result was that the main thread was cured of lag if only there was actual terrain currently the height at each point is determined by unity's default pearand noise function but this was a poorly made function therefore I fabricated my own bip plagiarizing code from Wikipedia's per pearlin noise article which has been expunged for absolutely no good reason a symptom plaguing all Wikipedia articles my
pearlin noise could be improved by adding more pearing noise each one having higher scaling the result is more rugged grasslands but instead of making the height equal to the plin noise it could be two to the power of the plin noise this exponential function creates a mix of grasslands and mountain ranges on the distant Skyline this could be further improved by effectuating trees to obtain vast Landscapes of forests stretching into the distance however this is still barely a game due to the disheartening lack of gaming and what better gaming to add than the mining part
of Minecraft this requires knowing which block is in front of me simply from my facing Direction and World data for this I sought help in the ninth layer of the internet forums programming forums are rather Infamous for harboring internet micro professionals a close cousin of the internet micro celebrity but there is the occasional real answer this individual procured several lessay on finding which blocks overlap with a line of sight until he tragically vanished so I continued this Theory to assemble my own skitso post also known as sudo code a helpful stepping stone to visualize ideas
before making the real algorithm now that Mining and placing were invented the trifecta was nearly completed I only needed a gamer now now introducing this 1.1 152 cubic met convex polyhedron game object player movement was easily effectuated but adding gravity caused disastrous consequences I needed Collision detection between players and blocks which was accomplished with the same block detection methods used for mining but after some contemplation I realized the conspiracy theories Link in factorial and software engineering were factual but now that I had a gamer this begs the question of whether it was possible to have
multiple Gamers using multiplayer the server didn't need to be anything fancy my server is simply a constantly running program that sends and receives data to ensure all players are synchronized however only ones and zeros can be sent through the network meaning the server must convert outgoing game information into bites a process known as serialization clients theny serialize incoming data to update their game syncing player positions was rather easy but attemp ing to serialize the entire world would consume 13 Samsung t7 portable SSD external solid state dries worth of data on the other hand games like
no man's Sky accommodate 18 quintilian entire planets while storing very little data on the server by only saving changes this inspires my proposition the same world seed makes the same world every time by only sending the seed players could generate the rest of the world on their own chunks with changes are the the only other things sent this allowed multiplayer to function with a ridiculous render distance but the one thing I have neglected was rendering itself this game possessed the Hideous asset flip aesthetic and I was clueless as to how so-called AAA games achiev their
Graphics that was until some random discordian rambled about ambient occlusion a quick search reveals that it gives shading to edges adding this required configuring something called the rener pipeline which is essentially the five tatris Ian step process responsible for converting game objects into pixels on your screen but it was also incredibly configurable special effects could be injected near the end including ambient occlusion the result is a surprisingly considerable decrease in awfulness and another render pipeline feature to add was the godray effect technically known as volumetric lighting while most volumetric lighting effects use expensive Ray marching
calculus blah blah blah this simple 50 step tutorial uses a shortcut simply create a white picture obscured by all viewable objects from the camera and apply a radial blur effect the final texture is then simply fed into the pipeline to be combined with the screen but in order to control how objects themselves were rendered un necessitated shaders these were easily created with Shader graphs a scratch Club version of Shader programming nearly everything was configurable now the Shader is then assigned to a Mater material which is applied to whatever objects I pleased shaders were needed to
obtain realistic water and I found this prog God hacker tutorial covering 59 tetrac silan steps per a a second to create this overly complicated Shader after applying it the result is that shallow water refracts whatever is below while deeper water reflects whatever is above speaking of what is above shaders could be applied to the sky itself with enough trial and error the real life atmosphere was created with various mathematical functions values in the Shader could then be updated constantly from outside code to simulate a daytime cycle fog is then applied to fade further terrain into
the atmosphere the final missing feature was Shadows but the default Shadows were inadequate due to their minuscule maximum distance this can be circumvented with several Shadow Cascades each Cascade is a ring of increasingly farther Shadows each having lower resolution to help performance the Graphics were now comparable to Minecraft top tiine shaders while maintaining a tolerable performance despite having mediocre Hardware but you may have noticed this profoundly discordant graphical predicament the jaggedness of everything also known as aliasing the solution to this was surprisingly easy left clicking this option to enable temporal anti-aliasing this sounds less fancy
than the other options but somehow has higher quality for reasons I cannot disclose finally this game meets my graphical expectations but this video has only covered approximately 25% of the actual effort spent on this game development shall probably continue but do not expect a public release in case this catastrophically fails so goodbye