From 1595468babf462e1e4c183ebdd9751a135babd3f Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 8 Feb 2020 14:48:15 +0100 Subject: [PATCH] Bug fixes in the graph view code (variable initialized too late) and the TEX3D blend node (function name collision with blend node). --- addons/material_maker/nodes/tex3d_blend.mmg | 4 ++-- material_maker/graph_edit.gd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/material_maker/nodes/tex3d_blend.mmg b/addons/material_maker/nodes/tex3d_blend.mmg index e3069fc..1436b34 100644 --- a/addons/material_maker/nodes/tex3d_blend.mmg +++ b/addons/material_maker/nodes/tex3d_blend.mmg @@ -6,11 +6,11 @@ }, "parameters": { "amount": 1, - "blend_type": 0 + "blend_type": 1 }, "shader_model": { "code": "", - "global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_overlay_f(c1.x, c2.x), blend3d_overlay_f(c1.y, c2.y), blend3d_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_soft_light_f(c1.x, c2.x), blend3d_soft_light_f(c1.y, c2.y), blend3d_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_burn_f(c1.x, c2.x), blend3d_burn_f(c1.y, c2.y), blend3d_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_dodge_f(c1.x, c2.x), blend3d_dodge_f(c1.y, c2.y), blend3d_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n", + "global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_overlay_f(c1.x, c2.x), blend3d_overlay_f(c1.y, c2.y), blend3d_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_soft_light_f(c1.x, c2.x), blend3d_soft_light_f(c1.y, c2.y), blend3d_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_burn_f(c1.x, c2.x), blend3d_burn_f(c1.y, c2.y), blend3d_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend3d_dodge_f(c1.x, c2.x), blend3d_dodge_f(c1.y, c2.y), blend3d_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n", "inputs": [ { "default": "vec3($uv.x, 1.0, 1.0)", diff --git a/material_maker/graph_edit.gd b/material_maker/graph_edit.gd index 6a2fa27..d9396a9 100644 --- a/material_maker/graph_edit.gd +++ b/material_maker/graph_edit.gd @@ -350,8 +350,8 @@ func create_subgraph() -> void: func _on_ButtonShowTree_pressed() -> void: var graph_tree : Popup = preload("res://material_maker/widgets/graph_tree/graph_tree.tscn").instance() - graph_tree.init("Top", top_generator) add_child(graph_tree) + graph_tree.init("Top", top_generator) graph_tree.connect("item_double_clicked", self, "edit_subgraph") graph_tree.popup_centered()