0 votes

Hello all, I am making a minecraft inspired game but I am currently making the cube/block I have the block done but now I want to add a texture to it, like in minecraft having a grass block but when I try to add a texture it just renders in a single colour, how do I add a texture to my mesh, I think I need to use UVs but I have no clue if I done it correct or not!

here is the code:https://pasteall.org/pvnm

Godot version 3.2.3
in Engine by (152 points)

1 Answer

0 votes

Games like minecraft uses what is called a texture atlas, a texture atlas is a single image file that contains all the textures needed in the game and stitches them together, uv values are mapped as 0 and 1 so in order to use a specific part of the image the uv values for each vertex needs to differ

For example, say your texture atlas contains 4 textures in a 2x2 matrix and you want to use the top right texture for your blocks, the uv values for the top right texture needs to be (0.5, 0.0), (1.0, 0.0), (0.5, 0.5), and (1.0, 0.5) as no matter what size the image is the uv coordinates are mapped into 0 and 1

by (60 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.