Godot Version
v4.3
Question
I’ve been trying to utilize “live” painting effects in the game I’m working on, and am running into some trouble. I found this useful project someone worked on a while back, but it’s unfortunately in Godot 3, which I’m working in 4.3 ( Project: Godot Engine In-game Splat Map Texture Painting (Dirt Removal Effect) - Alfred Reinold Baudisch )
I managed to convert the shader and scripts over to Godot 4 compatible format, and the game works and shader looks correct in all the ways - even confirmed w/ a custom mask on it. However, I’m running into one issue: Clicking doesn’t seem to paint on the object. I was able to narrow it down to get_vertex_uv, and found something super confusing, in which I’m seeing no other people mention - so wondering if this is something I’m doing wrong in my conversion of this code.
Basically, I’ve got the get_uv_coords
method that was written, as the following:
func get_uv_coords(point, normal, transform = true) -> Vector2:
# Gets the uv coordinates on the mesh given a point on the mesh and normal
# these values can be obtained from a raycast
transform_vertex_to_global = transform
var face = get_face(point, normal)
if face.is_empty():
return -Vector2.ONE
var bc = face[2]
var uv1 = meshtool.get_vertex_uv(_local_face_vertices[face[0]][0])
var uv2 = meshtool.get_vertex_uv(_local_face_vertices[face[0]][1])
var uv3 = meshtool.get_vertex_uv(_local_face_vertices[face[0]][2])
return (uv1 * bc.x) + (uv2 * bc.y) + (uv3 * bc.z)
I added some debug statements and all that to right before get_vertex_uv, and compared the conversion to the original project in a separate installation of Godot 3… And I verified the face values and all that are exactly the same, however, get_vertex_uv in Godot 4 keeps returning values like the following to me:
What reasons would this method result in such crazy values, and is there a different way I should be doing this check to get the uv coordinate in Godot 4 vs. 3? Or is this just a bug no one’s reported (and if so - any suggestions on a way around it?)