-
-
Notifications
You must be signed in to change notification settings - Fork 5
Block shapes #2
Comments
Hi there! So like the readme says, the only shape available is the block/cube shape and they are hardcoded. The blocks are built within a job that you can find in BuildChunkJob. It works in a relatively simple fashion. I'll go over how it builds the north face, as it is the first in the process, and then I think you can figure out how all the other faces are built. It starts with looping over the chunk size for each axis, x, y, and z. For each loop on the Z-axis, as it is the last, it increases an index by one since you can only a one-dimensional array in jobs. It uses said index to find a block in the "block map" which is the map of blocks within a chunk. And that is basically how it creates the blocks. I hope this helped and if you have any more questions, don't hesitate to ask them either here or by email! :) [1] The IsTransparent method checks for more than just transparency. First of all, it checks if it's an air block, which is always transparent. Then it checks if the next block is transparent but it shouldn't connect to itself (Think like glass in Minecraft. You don't see the glass faces from other glass blocks). Then it checks if it is transparent and it should connect to itself. Then it needs to make sure the next block has the same ID as the current block. It's useful to see if it should connect to itself or not. Blocks like leaves in Minecraft are transparent but don't connect to each other, while glass is also transparent and it connects to each other. (And with connecting I mean hiding faces you normally won't see) [2] The texture coordinates are calculated in the GenerateAtlas method in TextureProvider. It takes all the unique textures, packs them all into an atlas and then maps each texture to a coordinate on the atlas. Since the Unity method PackTextures returns a rect, we can use this to figure out where each texture is on the map. |
Thanks for the quick response! I actually already started working on a method to author custom mesh shapes, just need to add some management system for it. Could probably make a push after I'm done if you're interested. For the shader though, it's going to be a bit more difficult since texture arrays require a custom editor, but the possibility of having textures tiled over multiple blocks seems too nice to pass on. I'll try to figure something out. Anyway, you can leave this open to serve as a Q&A of sorts for any possible future inquirers or just close it. I'll send you an email once I have something to show. |
Any contribution would be awesome! The reason I decided to go with a texture atlas was because it's more backward-compatible than texture arrays. Textures arrays aren't really something new either but you never know. If anything, it's a good backup system if one could implement them side by side. I hope this clears things up a bit! |
Hi |
Hey, was just about to check it. No emails. |
I don't use Discord much but you can still contact me there if you'd like more direct communication. (Response time may vary) Hertzole#5580 |
@Hertzole hey, i really like this framework and want to use it for a project. I want to make use of texture arrays and possibly add texture blending shaders to it, but I need to get a better handle on how the block building process is done. Would be really great if you could give me some directions. Shoot me an email at [email protected] if you don't mind some direct communication.
The text was updated successfully, but these errors were encountered: