+2 votes

I started making a minecraft-like game and faced a problem: I have textures for different sides of the blocks, but I don't know how to create a .Materials file from the texture png. Sorry for my bad English

Godot version 3
in Engine by (90 points)

1 Answer

0 votes

Create a Cube in blender, assign one material to each side of the cube there. Export mesh as .gltf with materials set to "placeholder".
In Godot You will have a MeshInstance of your cube. You can choose materials property in editor, and You will see 6 surface slots. Create new shader material there, new shader, with this code:

shader_type spatial;
uniform sampler2D image;

void fragment():
      ALBEDO = texture(image,UV).xyz ;

didn't test it, I hope I didn;t make syntax error :)
Anyways, now when You choose any of your material, You will see new property imageunder shader parameters. Input your texture there, and it should work.

by (8,099 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 Frequently asked questions and 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 [email protected] with your username.