Skip to content

Commit

Permalink
Started fixing painting
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Dec 7, 2024
1 parent 4238c96 commit 9bf98fd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
6 changes: 3 additions & 3 deletions material_maker/panels/paint/paint.gd
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func update_view():
# DEBUG: show tex2view texture on model
#for i in range(10):
# await get_tree().process_frame
#painted_mesh.get_surface_override_material(0).albedo_texture = painter.debug_get_texture(1)
#painted_mesh.get_surface_override_material(0).albedo_texture = await painter.debug_get_texture(1)
# Force recalculate brush size parameter
#_on_Brush_value_changed(brush_parameters.brush_size, "brush_size")

Expand Down Expand Up @@ -912,8 +912,8 @@ func _on_ChannelSelect_item_selected(ID):
func debug_get_texture_names():
return [ "Mask" ]

func debug_get_texture(_ID):
return mask
func debug_get_texture(_ID) -> Texture2D:
return await mask.get_texture()

# Brush options UI

Expand Down
17 changes: 9 additions & 8 deletions material_maker/panels/paint/paint_layers.gd
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,20 @@ func debug_get_texture_names():
# tr("Depth")
# tr("Occlusion")

func debug_get_texture(ID):
func debug_get_texture(ID) -> Texture2D:
match ID:
0:
return get_albedo_texture()
return await get_albedo_texture()
1:
return get_metallic_texture()
return await get_metallic_texture()
2:
return get_roughness_texture()
return await get_roughness_texture()
3:
return get_emission_texture()
return await get_emission_texture()
4:
return get_normal_map()
return await get_normal_map()
5:
return get_depth_texture()
return await get_depth_texture()
6:
return get_occlusion_texture()
return await get_occlusion_texture()
return null
2 changes: 1 addition & 1 deletion material_maker/tools/painter/brush_preview.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func set_brush(brush) -> Texture2D:
await get_tree().process_frame
if DEBUG:
for i in painter.debug_get_texture_names().size():
var t = painter.debug_get_texture(i)
var t = await painter.debug_get_texture(i)
t.get_data().save_png("d:/debug_brush_preview_%d.png" % i)
initialized = true
return $SubViewport.get_texture()
45 changes: 24 additions & 21 deletions material_maker/tools/painter/painter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func update_view_textures():

func update_textures() -> void:
await MMMapGenerator.generate(mesh, "seams", texture_size, mesh_seams_tex)
await mesh_seams_tex.get_texture()

update_view_textures()

Expand Down Expand Up @@ -556,8 +557,7 @@ func on_dep_update_value(buffer_name : String, parameter_name : String, value) -
if suffix == "brush":
print("brush")
if value is MMTexture:
print("Is a texture")
brush_preview_material.set_shader_parameter(parameter_name, value.get_texture())
brush_preview_material.set_shader_parameter(parameter_name, await value.get_texture())
else:
brush_preview_material.set_shader_parameter(parameter_name, value)
elif suffix == "paint":
Expand Down Expand Up @@ -687,40 +687,43 @@ func debug_get_texture_names():
# tr("Depth/Occlusion (current layer)")
# tr("Mask (current layer)")

func debug_get_texture(ID):
func debug_get_texture(ID) -> Texture2D:
var texture : MMTexture
match debug_get_texture_names()[ID]:
"View to texture":
return await v2t_texture.get_texture()
texture = v2t_texture
"Texture to view":
return await t2v_texture.get_texture()
texture = t2v_texture
"Seams":
return await mesh_seams_tex.get_texture()
texture = mesh_seams_tex
"Albedo (current layer)":
return await get_paint_channel(CHANNEL_ALBEDO).next_texture.get_texture()
texture = get_paint_channel(CHANNEL_ALBEDO).next_texture
"Albedo previous (current layer)":
return await get_paint_channel(CHANNEL_ALBEDO).texture.get_texture()
texture = get_paint_channel(CHANNEL_ALBEDO).texture
"Albedo stroke (current layer)":
return await get_paint_channel(CHANNEL_ALBEDO).stroke.get_texture()
texture = get_paint_channel(CHANNEL_ALBEDO).stroke
"Metallic/Roughness (current layer)":
return await get_paint_channel(CHANNEL_MR).next_texture.get_texture()
texture = get_paint_channel(CHANNEL_MR).next_texture
"Metallic/Roughness stroke (current layer)":
return await get_paint_channel(CHANNEL_MR).stroke.get_texture()
texture = get_paint_channel(CHANNEL_MR).stroke
"Emission (current layer)":
return await get_paint_channel(CHANNEL_EMISSION).next_texture.get_texture()
texture = get_paint_channel(CHANNEL_EMISSION).next_texture
"Emission stroke (current layer)":
return await get_paint_channel(CHANNEL_EMISSION).stroke.get_texture()
texture = get_paint_channel(CHANNEL_EMISSION).stroke
"Normal (current layer)":
return await get_paint_channel(CHANNEL_NORMAL).next_texture.get_texture()
texture = get_paint_channel(CHANNEL_NORMAL).next_texture
"Normal stroke (current layer)":
return await get_paint_channel(CHANNEL_NORMAL).stroke.get_texture()
texture = get_paint_channel(CHANNEL_NORMAL).stroke
"Depth/Occlusion (current layer)":
return await get_paint_channel(CHANNEL_DO).next_texture.get_texture()
texture = get_paint_channel(CHANNEL_DO).next_texture
"Depth/Occlusion stroke (current layer)":
return await get_paint_channel(CHANNEL_DO).stroke.get_texture()
texture = get_paint_channel(CHANNEL_DO).stroke
"Mesh position map":
return mesh_position_tex
texture = mesh_position_tex
"Mesh normal map":
return mesh_normal_tex
texture = mesh_normal_tex
"Mesh tangent map":
return mesh_tangent_tex
return null
texture = mesh_tangent_tex
_:
return null
return await texture.get_texture()

0 comments on commit 9bf98fd

Please sign in to comment.