diff --git a/addons/material_maker/nodes/sdf3d_color.mmg b/addons/material_maker/nodes/sdf3d_color.mmg index 8301c7762..00acc1913 100644 --- a/addons/material_maker/nodes/sdf3d_color.mmg +++ b/addons/material_maker/nodes/sdf3d_color.mmg @@ -1,12 +1,11 @@ { - "generic_size": 1, "name": "sdf3d_color", "node_position": { "x": 0, "y": 0 }, "parameters": { - "c1": 0.5 + "c": 0.5 }, "seed_int": 0, "shader_model": { @@ -17,8 +16,8 @@ "default": "0.0", "label": "", "longdesc": "The input 3D object", - "name": "in#", - "shortdesc": "Input#", + "name": "in", + "shortdesc": "Input", "type": "sdf3d" } ], @@ -28,8 +27,8 @@ "outputs": [ { "longdesc": "The colored 3D object", - "sdf3dc": "vec2($in#($uv), $c#)", - "shortdesc": "Output#", + "sdf3dc": "vec2($in($uv), $c)", + "shortdesc": "Output", "type": "sdf3dc" } ], @@ -41,7 +40,7 @@ "longdesc": "The color index to be assigned", "max": 1, "min": 0, - "name": "c#", + "name": "c", "shortdesc": "Color", "step": 0.01, "type": "float" diff --git a/addons/material_maker/nodes/sdf3d_color_v.mmg b/addons/material_maker/nodes/sdf3d_color_v.mmg new file mode 100644 index 000000000..8301c7762 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_color_v.mmg @@ -0,0 +1,53 @@ +{ + "generic_size": 1, + "name": "sdf3d_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "c1": 0.5 + }, + "seed_int": 0, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input 3D object", + "name": "in#", + "shortdesc": "Input#", + "type": "sdf3d" + } + ], + "instance": "", + "longdesc": "Assigns a color index to a 3D object", + "name": "Color", + "outputs": [ + { + "longdesc": "The colored 3D object", + "sdf3dc": "vec2($in#($uv), $c#)", + "shortdesc": "Output#", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The color index to be assigned", + "max": 1, + "min": 0, + "name": "c#", + "shortdesc": "Color", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Color" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/tex3d_blend.mmg b/addons/material_maker/nodes/tex3d_blend.mmg index 81dc0d902..200b8000e 100644 --- a/addons/material_maker/nodes/tex3d_blend.mmg +++ b/addons/material_maker/nodes/tex3d_blend.mmg @@ -1,27 +1,16 @@ { - "generic_size": 1, "name": "tex3d_blend", "node_position": { "x": 0, "y": 0 }, "parameters": { - "amount1": 0.5, - "blend_type1": 0 + "amount": 0.5, + "blend_type": 0 }, "seed_int": 0, "shader_model": { - "code": [ - "vec3 $(name_uv)_b = $b($uv);", - "vec3 $(name_uv)_l;", - "vec3 $(name_uv)_a;", - "#for", - "$(name_uv)_l = $l#($uv);", - "$(name_uv)_a = $amount#*$a#($uv);", - "$(name_uv)_b = blend3d_$blend_type#($(name_uv)_l.rgb, $(name_uv)_b.rgb, $amount#*dot($a#($uv), vec3(1.0))/3.0 );", - "#end", - "" - ], + "code": "", "global": [ "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {", "\treturn opacity*c1 + (1.0-opacity)*c2;", @@ -87,26 +76,26 @@ "inputs": [ { "default": "vec3($uv.x, 1.0, 1.0)", - "label": "Background", + "label": "Source1", "longdesc": "The foreground input", - "name": "b", + "name": "s1", "shortdesc": "Foreground", "type": "tex3d" }, { "default": "vec3(1.0, $uv.y, 1.0)", - "label": "Layer#", + "label": "Source2", "longdesc": "The background input", - "name": "l#", + "name": "s2", "shortdesc": "Background", "type": "tex3d" }, { "default": "vec3(1.0)", - "label": "Opacity#", + "label": "Opacity", "longdesc": "The optional opacity mask", - "name": "a#", - "shortdesc": "Mask#", + "name": "a", + "shortdesc": "Mask", "type": "tex3d" } ], @@ -117,16 +106,16 @@ { "longdesc": "The 3D texture generated by the blend operation", "shortdesc": "Output", - "tex3d": "$(name_uv)_b", + "tex3d": "blend3d_$blend_type($s1($uv).rgb, $s2($uv).rgb, $amount*dot($a($uv), vec3(1.0))/3.0)", "type": "tex3d" } ], "parameters": [ { "default": 0, - "label": "2:", + "label": "", "longdesc": "The algorithm used to blend the inputs", - "name": "blend_type#", + "name": "blend_type", "shortdesc": "Blend mode", "type": "enum", "values": [ @@ -183,7 +172,7 @@ "longdesc": "The opacity of the blend operation", "max": 1, "min": 0, - "name": "amount#", + "name": "amount", "shortdesc": "Opacity", "step": 0, "type": "float" diff --git a/addons/material_maker/nodes/tex3d_blend_v.mmg b/addons/material_maker/nodes/tex3d_blend_v.mmg new file mode 100644 index 000000000..c240707a9 --- /dev/null +++ b/addons/material_maker/nodes/tex3d_blend_v.mmg @@ -0,0 +1,195 @@ +{ + "generic_size": 1, + "name": "tex3d_blend", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount1": 0.5, + "blend_type1": 0 + }, + "seed_int": 0, + "shader_model": { + "code": [ + "vec3 $(name_uv)_b = $b($uv);", + "vec3 $(name_uv)_l;", + "vec3 $(name_uv)_a;", + "#for", + "$(name_uv)_l = $l#($uv);", + "$(name_uv)_a = $amount#*$a#($uv);", + "$(name_uv)_b = blend3d_$blend_type#($(name_uv)_l.rgb, $(name_uv)_b.rgb, $amount#*dot($a#($uv), vec3(1.0))/3.0 );", + "#end", + "" + ], + "global": [ + "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*c1 + (1.0-opacity)*c2;", + "}", + "", + "vec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*c1*c2 + (1.0-opacity)*c2;", + "}", + "", + "vec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;", + "}", + "", + "float blend3d_overlay_f(float c1, float c2) {", + "\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));", + "}", + "", + "vec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {", + "\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;", + "}", + "", + "vec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;", + "}", + "", + "float blend3d_soft_light_f(float c1, float c2) {", + "\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);", + "}", + "", + "vec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {", + "\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;", + "}", + "", + "float blend3d_burn_f(float c1, float c2) {", + "\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);", + "}", + "", + "vec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {", + "\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;", + "}", + "", + "float blend3d_dodge_f(float c1, float c2) {", + "\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);", + "}", + "", + "vec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {", + "\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;", + "}", + "", + "vec3 blend3d_lighten(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;", + "}", + "", + "vec3 blend3d_darken(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;", + "}", + "", + "vec3 blend3d_difference(vec3 c1, vec3 c2, float opacity) {", + "\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;", + "}", + "" + ], + "inputs": [ + { + "default": "vec3($uv.x, 1.0, 1.0)", + "label": "Background", + "longdesc": "The background input", + "name": "b", + "shortdesc": "Background", + "type": "tex3d" + }, + { + "default": "vec3(1.0, $uv.y, 1.0)", + "label": "Layer#", + "longdesc": "A layer input", + "name": "l#", + "shortdesc": "Layer#", + "type": "tex3d" + }, + { + "default": "vec3(1.0)", + "label": "Opacity#", + "longdesc": "The optional opacity mask", + "name": "a#", + "shortdesc": "Mask#", + "type": "tex3d" + } + ], + "instance": "", + "longdesc": "Blends its 3D texture inputs, using an optional mask", + "name": "TEX3D Blend", + "outputs": [ + { + "longdesc": "The 3D texture generated by the blend operation", + "shortdesc": "Output", + "tex3d": "$(name_uv)_b", + "type": "tex3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "2:", + "longdesc": "The algorithm used to blend the inputs", + "name": "blend_type#", + "shortdesc": "Blend mode", + "type": "enum", + "values": [ + { + "name": "Normal", + "value": "normal" + }, + { + "name": "Multiply", + "value": "multiply" + }, + { + "name": "Screen", + "value": "screen" + }, + { + "name": "Overlay", + "value": "overlay" + }, + { + "name": "Hard Light", + "value": "hard_light" + }, + { + "name": "Soft Light", + "value": "soft_light" + }, + { + "name": "Burn", + "value": "burn" + }, + { + "name": "Dodge", + "value": "dodge" + }, + { + "name": "Lighten", + "value": "lighten" + }, + { + "name": "Darken", + "value": "darken" + }, + { + "name": "Difference", + "value": "difference" + } + ] + }, + { + "control": "None", + "default": 0.5, + "label": "3:", + "longdesc": "The opacity of the blend operation", + "max": 1, + "min": 0, + "name": "amount#", + "shortdesc": "Opacity", + "step": 0, + "type": "float" + } + ], + "shortdesc": "Tex3D Blend" + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/tex3d_select.mmg b/addons/material_maker/nodes/tex3d_select.mmg index 3d5ea7503..83afc9713 100644 --- a/addons/material_maker/nodes/tex3d_select.mmg +++ b/addons/material_maker/nodes/tex3d_select.mmg @@ -1,41 +1,32 @@ { - "generic_size": 1, "name": "tex3d_select", "node_position": { "x": 0, "y": 0 }, "parameters": { - "t1": 0.01, - "v1": 1 + "t": 0.01, + "v": 0.5 }, "seed_int": 0, "shader_model": { - "code": [ - "vec3 $(name_uv)_b = $b($uv);", - "float $(name_uv)_d = 0.0;", - "", - "#for", - "$(name_uv)_d = ($uv.w-$v#)/$t#;", - "$(name_uv)_b = mix($(name_uv)_b, $i#($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0));", - "#end" - ], + "code": "float $(name_uv)_d = ($uv.w-$v)/$t;", "global": "", "inputs": [ { "default": "vec3(0.5)", "label": "", - "longdesc": "The 3D texture(s) associated to other color indices", - "name": "b", - "shortdesc": "Background", + "longdesc": "The 3D texture associated to the specified color index", + "name": "in1", + "shortdesc": "Input1", "type": "tex3d" }, { "default": "vec3(0.5)", "label": "", - "longdesc": "The 3D texture associated to the specified color index", - "name": "i#", - "shortdesc": "Input#", + "longdesc": "The 3D texture(s) associated to other color indices", + "name": "in2", + "shortdesc": "Input2", "type": "tex3d" } ], @@ -46,31 +37,31 @@ { "longdesc": "The merged 3D texture", "shortdesc": "Output", - "tex3d": "$(name_uv)_b", + "tex3d": "mix($in1($uv), $in2($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0))", "type": "tex3d" } ], "parameters": [ { "control": "None", - "default": 1, - "label": "2:Value", + "default": 0.5, + "label": "Value", "longdesc": "The value of the selected color index", "max": 1, "min": 0, - "name": "v#", - "shortdesc": "Value#", + "name": "v", + "shortdesc": "Value", "step": 0.01, "type": "float" }, { "control": "None", - "default": 0.01, - "label": "2:", + "default": 0.1, + "label": "Tolerance", "longdesc": "The tolerance used when comparing color indices", "max": 1, "min": 0.01, - "name": "t#", + "name": "t", "shortdesc": "Tolerance", "step": 0.001, "type": "float" diff --git a/addons/material_maker/nodes/tex3d_select_v.mmg b/addons/material_maker/nodes/tex3d_select_v.mmg new file mode 100644 index 000000000..3d5ea7503 --- /dev/null +++ b/addons/material_maker/nodes/tex3d_select_v.mmg @@ -0,0 +1,82 @@ +{ + "generic_size": 1, + "name": "tex3d_select", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "t1": 0.01, + "v1": 1 + }, + "seed_int": 0, + "shader_model": { + "code": [ + "vec3 $(name_uv)_b = $b($uv);", + "float $(name_uv)_d = 0.0;", + "", + "#for", + "$(name_uv)_d = ($uv.w-$v#)/$t#;", + "$(name_uv)_b = mix($(name_uv)_b, $i#($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0));", + "#end" + ], + "global": "", + "inputs": [ + { + "default": "vec3(0.5)", + "label": "", + "longdesc": "The 3D texture(s) associated to other color indices", + "name": "b", + "shortdesc": "Background", + "type": "tex3d" + }, + { + "default": "vec3(0.5)", + "label": "", + "longdesc": "The 3D texture associated to the specified color index", + "name": "i#", + "shortdesc": "Input#", + "type": "tex3d" + } + ], + "instance": "", + "longdesc": "Selects a 3D texture for a given color index. This can be used to map several textures into a single 3D scene.", + "name": "TEX3D Select", + "outputs": [ + { + "longdesc": "The merged 3D texture", + "shortdesc": "Output", + "tex3d": "$(name_uv)_b", + "type": "tex3d" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "2:Value", + "longdesc": "The value of the selected color index", + "max": 1, + "min": 0, + "name": "v#", + "shortdesc": "Value#", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.01, + "label": "2:", + "longdesc": "The tolerance used when comparing color indices", + "max": 1, + "min": 0.01, + "name": "t#", + "shortdesc": "Tolerance", + "step": 0.001, + "type": "float" + } + ], + "shortdesc": "Tex3D Select" + }, + "type": "shader" +} \ No newline at end of file diff --git a/material_maker/library/base.json b/material_maker/library/base.json index 1b73533b0..d25a37bd5 100644 --- a/material_maker/library/base.json +++ b/material_maker/library/base.json @@ -866,7 +866,7 @@ "c": 0.5 }, "tree_item": "3D/SDF/Color", - "type": "sdf3d_color" + "type": "sdf3d_color_v" }, { "icon": "3d_sdf_shapes_sphere", @@ -1163,7 +1163,7 @@ "v": 1 }, "tree_item": "3D/Texture/Select", - "type": "tex3d_select" + "type": "tex3d_select_v" }, { "icon": "3d_texture_from2d", @@ -1215,7 +1215,7 @@ "blend_type": 0 }, "tree_item": "3D/Texture/Blend", - "type": "tex3d_blend" + "type": "tex3d_blend_v" }, { "icon": "3d_texture_colorize",