mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Display value on slider and import improvements (support for ORM textures)
This commit is contained in:
parent
8c06cd3aa8
commit
8ed10ccd02
@ -9,19 +9,9 @@ var generated_textures = {}
|
||||
|
||||
const TEXTURE_LIST = [
|
||||
{ port=0, texture="albedo" },
|
||||
{ port=1, texture="metallic" },
|
||||
{ port=2, texture="roughness" },
|
||||
{ port=3, texture="emission" },
|
||||
{ port=4, texture="normal_texture" },
|
||||
{ port=5, texture="ao_texture" },
|
||||
{ port=6, texture="depth_texture" }
|
||||
]
|
||||
|
||||
const ADDON_TEXTURE_LIST = [
|
||||
{ port=0, texture="albedo" },
|
||||
{ port=3, texture="emission" },
|
||||
{ port=4, texture="normal_texture" },
|
||||
{ ports=[5, 1, 2], default_values=["1.0", "0.0", "1.0"], texture="orm" },
|
||||
{ ports=[5, 2, 1], default_values=["1.0", "1.0", "1.0"], texture="orm" },
|
||||
{ port=6, texture="depth_texture" }
|
||||
]
|
||||
|
||||
@ -64,16 +54,37 @@ func source_changed(input_index : int):
|
||||
|
||||
func render_textures(renderer : MMGenRenderer):
|
||||
for t in texture_list:
|
||||
var texture = null
|
||||
if t.has("port"):
|
||||
var source = get_source(t.port)
|
||||
var texture = null
|
||||
if source != null:
|
||||
var status = source.generator.render(source.output_index, renderer, 1024)
|
||||
while status is GDScriptFunctionState:
|
||||
status = yield(status, "completed")
|
||||
texture = ImageTexture.new()
|
||||
texture.create_from_image(renderer.get_texture().get_data())
|
||||
generated_textures[t.texture] = texture
|
||||
elif t.has("ports"):
|
||||
var context : MMGenContext = MMGenContext.new(renderer)
|
||||
var code = []
|
||||
var shader_textures = {}
|
||||
for i in range(t.ports.size()):
|
||||
var source = get_source(t.ports[i])
|
||||
if source != null:
|
||||
var status = source.generator.get_shader_code("UV", source.output_index, context)
|
||||
while status is GDScriptFunctionState:
|
||||
status = yield(status, "completed")
|
||||
code.push_back(status)
|
||||
for t in status.textures.keys():
|
||||
shader_textures[t] = code.textures[t]
|
||||
else:
|
||||
code.push_back({ defs="", code="", f=t.default_values[i] })
|
||||
var shader : String = renderer.generate_combined_shader(code[0], code[1], code[2])
|
||||
var status = renderer.render_shader(shader, shader_textures, 1024)
|
||||
while status is GDScriptFunctionState:
|
||||
status = yield(status, "completed")
|
||||
texture = ImageTexture.new()
|
||||
texture.create_from_image(renderer.get_texture().get_data())
|
||||
generated_textures[t.texture] = texture
|
||||
|
||||
func update_materials(material_list):
|
||||
for m in material_list:
|
||||
@ -95,15 +106,14 @@ func update_spatial_material(m, file_prefix = null):
|
||||
m.albedo_texture = get_generated_texture("albedo", file_prefix)
|
||||
m.metallic = parameters.metallic
|
||||
m.roughness = parameters.roughness
|
||||
if false:
|
||||
texture = get_generated_texture("mrao", file_prefix)
|
||||
m.metallic_texture = texture
|
||||
m.metallic_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_RED
|
||||
m.roughness_texture = texture
|
||||
m.roughness_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_GREEN
|
||||
else:
|
||||
m.metallic_texture = get_generated_texture("metallic", file_prefix)
|
||||
m.roughness_texture = get_generated_texture("roughness", file_prefix)
|
||||
# Metallic
|
||||
texture = get_generated_texture("orm", file_prefix)
|
||||
m.metallic_texture = texture
|
||||
m.metallic_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_BLUE
|
||||
# Roughness
|
||||
m.roughness_texture = texture
|
||||
m.roughness_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_GREEN
|
||||
# Emission
|
||||
texture = get_generated_texture("emission", file_prefix)
|
||||
if texture != null:
|
||||
m.emission_enabled = true
|
||||
@ -111,28 +121,22 @@ func update_spatial_material(m, file_prefix = null):
|
||||
m.emission_texture = texture
|
||||
else:
|
||||
m.emission_enabled = false
|
||||
# Normal map
|
||||
texture = get_generated_texture("normal_texture", file_prefix)
|
||||
if texture != null:
|
||||
m.normal_enabled = true
|
||||
m.normal_texture = texture
|
||||
else:
|
||||
m.normal_enabled = false
|
||||
if false:
|
||||
if (generated_textures.mrao.mask & (1 << 2)) != 0:
|
||||
m.ao_enabled = true
|
||||
m.ao_light_affect = parameters.ao_light_affect
|
||||
m.ao_texture = m.metallic_texture
|
||||
m.ao_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_BLUE
|
||||
else:
|
||||
m.ao_enabled = false
|
||||
# Ambient occlusion
|
||||
if get_source(5) != null:
|
||||
m.ao_enabled = true
|
||||
m.ao_light_affect = parameters.ao_light_affect
|
||||
m.ao_texture = m.metallic_texture
|
||||
m.ao_texture_channel = SpatialMaterial.TEXTURE_CHANNEL_RED
|
||||
else:
|
||||
texture = get_generated_texture("ao_texture", file_prefix)
|
||||
if texture != null:
|
||||
m.ao_enabled = true
|
||||
m.ao_light_affect = parameters.ao_light_affect
|
||||
m.ao_texture = texture
|
||||
else:
|
||||
m.ao_enabled = false
|
||||
m.ao_enabled = false
|
||||
# Depth
|
||||
texture = get_generated_texture("depth_texture", file_prefix)
|
||||
if texture != null:
|
||||
m.depth_enabled = true
|
||||
|
@ -1,3 +1,4 @@
|
||||
tool
|
||||
extends EditorImportPlugin
|
||||
|
||||
var plugin = null
|
||||
|
@ -118,6 +118,7 @@ tab_align = 0
|
||||
tab_close_display_policy = 1
|
||||
|
||||
[node name="Renderer" parent="." instance=ExtResource( 5 )]
|
||||
size = Vector2( 1024, 1024 )
|
||||
debug_path = null
|
||||
|
||||
[node name="NodeFactory" type="Node" parent="."]
|
||||
@ -131,6 +132,12 @@ script = ExtResource( 6 )
|
||||
[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit" method="disconnect_node"]
|
||||
[connection signal="close_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material" method="on_close_request"]
|
||||
[connection signal="offset_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material" method="on_offset_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer2/metallic" method="update_label"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer3/roughness" method="update_label"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer4/emission_energy" method="update_label"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer5/normal_scale" method="update_label"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer6/ao_light_affect" method="update_label"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects/GraphEdit/node_Material/HBoxContainer7/depth_scale" method="update_label"]
|
||||
[connection signal="reposition_active_tab_request" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="move_active_tab_to"]
|
||||
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="set_current_tab"]
|
||||
[connection signal="tab_close" from="VBoxContainer/HBoxContainer/ProjectsPane/Projects/Tabs" to="VBoxContainer/HBoxContainer/ProjectsPane/Projects" method="close_tab"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://rodz_labs_logo.png" type="Texture" id=1]
|
||||
|
||||
@ -20,19 +20,22 @@ height = 3.0
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=6]
|
||||
albedo_texture = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=7]
|
||||
albedo_texture = ExtResource( 1 )
|
||||
uv1_scale = Vector3( 2, 2, 2 )
|
||||
uv1_offset = Vector3( 0, 0.5, 0 )
|
||||
|
||||
[sub_resource type="PlaneMesh" id=7]
|
||||
[sub_resource type="PlaneMesh" id=8]
|
||||
size = Vector2( 3, 3 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=8]
|
||||
[sub_resource type="SpatialMaterial" id=9]
|
||||
albedo_texture = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="PlaneMesh" id=9]
|
||||
[sub_resource type="PlaneMesh" id=10]
|
||||
size = Vector2( 12, 12 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=10]
|
||||
[sub_resource type="SpatialMaterial" id=11]
|
||||
albedo_texture = ExtResource( 1 )
|
||||
uv1_scale = Vector3( 4, 4, 4 )
|
||||
|
||||
@ -50,16 +53,20 @@ mesh = SubResource( 3 )
|
||||
material/0 = SubResource( 4 )
|
||||
|
||||
[node name="Sphere" type="MeshInstance" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource( 5 )
|
||||
material/0 = SubResource( 6 )
|
||||
|
||||
[node name="Sphere2" type="MeshInstance" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource( 5 )
|
||||
material/0 = SubResource( 7 )
|
||||
|
||||
[node name="Quad" type="MeshInstance" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource( 7 )
|
||||
material/0 = SubResource( 8 )
|
||||
mesh = SubResource( 8 )
|
||||
material/0 = SubResource( 9 )
|
||||
|
||||
[node name="Plane" type="MeshInstance" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource( 9 )
|
||||
material/0 = SubResource( 10 )
|
||||
mesh = SubResource( 10 )
|
||||
material/0 = SubResource( 11 )
|
||||
|
@ -9,4 +9,4 @@ func set_value(v):
|
||||
update_label(v)
|
||||
|
||||
func update_label(v):
|
||||
$Label.text = "%f" % v
|
||||
$Label.text = str(v)
|
@ -11,10 +11,10 @@ ticks_on_borders = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
self_modulate = Color( 1, 1, 1, 0.501961 )
|
||||
self_modulate = Color( 0.752941, 0.752941, 1, 1 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
text = "100"
|
||||
text = "0"
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
|
Loading…
Reference in New Issue
Block a user