Reputation: 9069
I'm attempting to set a texture on a quad that I generate with the surface tool. On the mesh instance I set a material override of spatial material. I then set the texture to a png file in the albedo section. The texture I am using is a 16 x 16 png with an alpha channel. The top half of the texture is red and bottom half is blue. When I run the code I see a quad that is one solid color and that is purple. I'm new to godot and am completely lost to what is wrong. Any help is appreciated.
extends MeshInstance
func _ready():
var surfTool = SurfaceTool.new()
var mesh = Mesh.new()
var vert_array = Array()
var uv_array = Array()
var st = SurfaceTool.new()
vert_array.push_back(Vector3(0,0,0))
vert_array.push_back(Vector3(0,1,0))
vert_array.push_back(Vector3(1,1,0))
vert_array.push_back(Vector3(0,0,0))
vert_array.push_back(Vector3(1,1,0))
vert_array.push_back(Vector3(1,0,0))
uv_array.push_back(Vector2(0,0))
uv_array.push_back(Vector2(0,1))
uv_array.push_back(Vector2(1,1))
uv_array.push_back(Vector2(0,0))
uv_array.push_back(Vector2(1,1))
uv_array.push_back(Vector2(1,0))
st.begin(Mesh.PRIMITIVE_TRIANGLES)
for i in range(6):
st.add_vertex(vert_array[i])
st.add_uv(uv_array[i])
st.commit(mesh)
self.set_mesh(mesh)
Upvotes: 0
Views: 3505
Reputation: 56
You can do it remotely in the inspection panel. go to geometry - material override - and make a new spatial material.
Upvotes: 1