0 votes

Hi, Community!

I am writing a mesh by SurfaceTool object in Godot 3.2.2. I try to set the colour of the mesh vertices and surfaces by adding a material with a colour, or by using MeshDataTool to access the vertices to change the colour. But the colour stays "Black". 

The following is my simple code:

 # mesh
var tmpMesh = Mesh.new()
var vertices = PoolVector3Array()
var mat = SpatialMaterial.new()
var color = Color(225,0,0,1)
var st = SurfaceTool.new()

# add color to the surface
mat.albedo_color = color

# draw mesh

for v in vertices.size():

mesh = tmpMesh

How could I fix it up?

Thank you in advance!


in Engine by (14 points)

var color = Color(225,0,0,1)

Note, 225 is crazy HDR bright. If you just want red, Color(1,0,0,1) should be enough

Thanks for the advice on coding!

1 Answer

+1 vote

try to add normals or

st.generate_normals ()

Before the commit!

This should help

by (4,088 points)

OK, I will have a try. Thank you!

set a normal doesn't actually work. It is a problem of material setting.

If I set: mat.flags_unshaded = true, it is able to work then.

if you set unshaded the normals dont get in effect so it must not be a material problem.

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.