First things first thank you all for 600 subscribers yay in this video i will go over how to texture a chunk using procedural uv mapping before we get started there will be two links in the description one pointing to a tech stock that has a series of read-only int arrays that Store the order in which certain uv coordinates will be added depending on the face’s direction the second link has a png file that represents the texture atlas that will be used for the duration of this series so go ahead and download those and when you are ready we can get into the Texturing of chunks in minecraft so immediately create a new c-sharp script called texture loader now in visual studio in the texture loader class create another class inside called cube texture also put on the system.serializable attribute so you can modify how blocks will look now in the cubetexture class create a String variable called texturename and three public sprite variables that each represent the sprite that will be displayed on each axis in the third dimension the texture name’s main purpose is so we can have an easier time creating and modifying blocks in the editor after that create another class Called face textures give this class the system.serializable attribute and in this class create public sprite variables for each side of a cube also create a public variable for this class in the cube texture class now add in a function that returns a vector 2 array called get uv at Direction which takes in a vector3 ant argument representing a direction this function checks the direction in each separate 3d axis and returns the sprite uvs accordingly if the specific axis texture variable is null it will resort to the specific face texture uvs and the null return at the end is to Take into account that each component in the vector3 end can be any real number besides one now in the main class create a serialized private cube texture array variable and a public dictionary that uses inc as keys and a cube texture as a value after this replace the start and update Method with the awake method and in this function initialize the textures dictionary with the cube textures array using a for loop now in the world generator class create a serialized private variable that uses the texture loader class as its type and moving straight into the chunk mesh creator class have its constructor take In a texture loader as an argument and assign the argument to a variable within the chunk mesh creator class after that go into the face data class and have the constructor in this class taking an interarray representing the uv order next up copy paste the uv order text file contents into the script And in the constructor for the chunk mesh creator add in the uv order arguments to the lines where face data instances are created make sure the face direction matches the uv order representing its axis now in the create mesh from data function add in a variable representing A list of vector twos called uvs in the part where actual geometry is added to the mesh get a reference to the block’s cube texture using the dictionary in the texture loader the block id being looped over will be the key after that use the get uvs at direction Function to get the uvs needed to add onto the mesh for the index use the uv index order array within the face data type also put these lines in the catch statement so if there is an error in the checking process it will match the uv count with the vertices count When that is complete use the mesh set uvs function to apply the uv list generated with that line complete go into the unity editor import the texture atlas from the description import the sprite 2d package and use a sprite editor to cut out 16 by 16 Sprites after that set the mesh type on the texture to be full racked attach the texture loader class onto the gamemaster or game object and from there add in cube textures for blocks one to four since they are being used in the generation and when you run the game and assign a Material with the atlas as the base map to the chunk you should get a nicely textured chunk like this and that is my rendition of how chunks are textured in minecraft in the next video i’m going to go over adding in a character controller and implementing infinite terrain generation there will Also be some optimizations that we can do so if you’re interested like and subscribe other than all that i hope to see you on the next video goodbye Video Information
This video, titled ‘How Minecraft Works | Chunk Texturing [C#] [Unity3D]’, was uploaded by Rytech on 2022-01-31 17:07:11. It has garnered 4787 views and 132 likes. The duration of the video is 00:06:16 or 376 seconds.
In this video, I go over how I recreated Minecraft’s chunk mesh generation. This series of ‘How Minecraft Works’ will go over how I recreated many features of Minecraft on my own, and the code behind it so you can learn from the process.
More Info on Meshes ► https://docs.unity3d.com/Manual/Gener…
Texture Atlas in Video ► https://www.mediafire.com/view/faaxq00souq713g,6g9dkhgv8bf9zm2/gallery#
UVIndexingOrder Text File ► https://www.mediafire.com/file/faaxq00souq713g/UVIndexingOrder.txt/file
Join my Discord! ► https://discord.gg/jrRJgfBz2y
-= Music =-
***************************************** Music: Dopamine Artist : DZGRIMX link to the video: https://youtu.be/3S6uyNk9HpY channel: https://www.youtube.com/channel/UCBhW… *****************************************