mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
More node editor progress, support for globals in generic nodes
This commit is contained in:
parent
0d85cd5aef
commit
938397f3f6
@ -184,107 +184,6 @@ vec2 transform_norepeat(vec2 uv, vec2 translate, float rotate, vec2 scale) {
|
|||||||
return clamp(transform(uv, translate, rotate, scale), vec2(0.0), vec2(1.0));
|
return clamp(transform(uv, translate, rotate, scale), vec2(0.0), vec2(1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float bevel) {
|
|
||||||
float color = 0.5;
|
|
||||||
vec2 c1 = (uv-bmin-vec2(mortar))/bevel;
|
|
||||||
vec2 c2 = (bmax-uv-vec2(mortar))/bevel;
|
|
||||||
vec2 c = min(c1, c2);
|
|
||||||
color = clamp(min(c.x, c.y), 0.0, 1.0);
|
|
||||||
return vec3(color, mod(bmin, vec2(1.0, 1.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_rb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
count *= repeat;
|
|
||||||
mortar /= max(count.x, count.y);
|
|
||||||
bevel /= max(count.x, count.y);
|
|
||||||
float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));
|
|
||||||
vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));
|
|
||||||
bmin.x += x_offset;
|
|
||||||
bmin /= count;
|
|
||||||
return brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
count *= repeat;
|
|
||||||
mortar /= max(2.0*count.x, count.y);
|
|
||||||
bevel /= max(2.0*count.x, count.y);
|
|
||||||
float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));
|
|
||||||
count.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5)));
|
|
||||||
vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));
|
|
||||||
bmin.x += x_offset;
|
|
||||||
bmin /= count;
|
|
||||||
return brick(uv, bmin, bmin+vec2(1.0)/count, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_hb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
float pc = count.x+count.y;
|
|
||||||
float c = pc*repeat;
|
|
||||||
mortar /= c;
|
|
||||||
bevel /= c;
|
|
||||||
vec2 corner = floor(uv*c);
|
|
||||||
float cdiff = mod(corner.x-corner.y, pc);
|
|
||||||
if (cdiff < count.x) {
|
|
||||||
return brick(uv, (corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c, mortar, bevel);
|
|
||||||
} else {
|
|
||||||
return brick(uv, (corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c, mortar, bevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_bw(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
vec2 c = 2.0*count*repeat;
|
|
||||||
float mc = max(c.x, c.y);
|
|
||||||
mortar /= mc;
|
|
||||||
bevel /= mc;
|
|
||||||
vec2 corner1 = floor(uv*c);
|
|
||||||
vec2 corner2 = count*floor(repeat*2.0*uv);
|
|
||||||
float cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0);
|
|
||||||
vec2 corner;
|
|
||||||
vec2 size;
|
|
||||||
if (cdiff == 0.0) {
|
|
||||||
corner = vec2(corner1.x, corner2.y);
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else {
|
|
||||||
corner = vec2(corner2.x, corner1.y);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
}
|
|
||||||
return brick(uv, corner/c, (corner+size)/c, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 bricks_sb(vec2 uv, vec2 count, float repeat, float offset, float mortar, float bevel) {
|
|
||||||
vec2 c = (count+vec2(1.0))*repeat;
|
|
||||||
float mc = max(c.x, c.y);
|
|
||||||
mortar /= mc;
|
|
||||||
bevel /= mc;
|
|
||||||
vec2 corner1 = floor(uv*c);
|
|
||||||
vec2 corner2 = (count+vec2(1.0))*floor(repeat*uv);
|
|
||||||
vec2 rcorner = corner1 - corner2;
|
|
||||||
vec2 corner;
|
|
||||||
vec2 size;
|
|
||||||
if (rcorner.x == 0.0 && rcorner.y < count.y) {
|
|
||||||
corner = corner2;
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else if (rcorner.y == 0.0) {
|
|
||||||
corner = corner2+vec2(1.0, 0.0);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
} else if (rcorner.x == count.x) {
|
|
||||||
corner = corner2+vec2(count.x, 1.0);
|
|
||||||
size = vec2(1.0, count.y);
|
|
||||||
} else if (rcorner.y == count.y) {
|
|
||||||
corner = corner2+vec2(0.0, count.y);
|
|
||||||
size = vec2(count.x, 1.0);
|
|
||||||
} else {
|
|
||||||
corner = corner2+vec2(1.0);
|
|
||||||
size = vec2(count.x-1.0, count.y-1.0);
|
|
||||||
}
|
|
||||||
return brick(uv, corner/c, (corner+size)/c, mortar, bevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
float colored_bricks(vec2 uv, vec2 count, float offset) {
|
|
||||||
float x = floor(uv.x*count.x+offset*step(0.5, fract(uv.y*count.y*0.5)));
|
|
||||||
float y = floor(uv.y*count.y);
|
|
||||||
return fract(x/3.0+y/7.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
float dots(vec2 uv, float size, float density, int seed) {
|
float dots(vec2 uv, float size, float density, int seed) {
|
||||||
vec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));
|
vec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));
|
||||||
uv /= size;
|
uv /= size;
|
||||||
|
@ -1 +1 @@
|
|||||||
{"connections":[{"from":"bricks_0","from_port":0,"to":"blend_0","to_port":0},{"from":"perlin_0","from_port":0,"to":"blend_0","to_port":1},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"perlin_1","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_1","to_port":1},{"from":"perlin_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_1","to_port":2},{"from":"blend_1","from_port":0,"to":"Material","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_2","to_port":0},{"from":"blend_2","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"normal_map_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"blend_2","to_port":1},{"from":"perlin_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_2","from_port":0,"to":"combine_0","to_port":1},{"from":"colorize_2","from_port":0,"to":"blend_1","to_port":0}],"nodes":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":938,"y":96},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"gradient":[{"b":0,"g":0,"pos":0.518182,"r":0},{"b":1,"g":1,"pos":0.709091,"r":1}],"name":"colorize_3","node_position":{"x":487.633789,"y":65},"type":"colorize"},{"bevel":0,"columns":5,"mortar":0.02,"name":"bricks_0","node_position":{"x":-1,"y":30.5},"pattern":0,"repeat":1,"row_offset":0.5,"rows":1,"type":"bricks"},{"gradient":[{"b":0,"g":0.336914,"pos":0,"r":0.598958},{"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"b":0,"g":0.357422,"pos":1,"r":0.635417}],"name":"colorize_0","node_position":{"x":472,"y":-41.5},"type":"colorize"},{"iterations":7,"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"persistence":0.55,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.4,"blend_type":0,"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"type":"blend"},{"iterations":6,"name":"perlin_2","node_position":{"x":232.633789,"y":40},"persistence":0.65,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.4,"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"type":"normal_map"},{"amount":0.5,"blend_type":0,"name":"blend_1","node_position":{"x":707.633789,"y":-68},"type":"blend"},{"amount":1,"blend_type":2,"name":"blend_0","node_position":{"x":271,"y":306.5},"type":"blend"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_5","node_position":{"x":503,"y":336.5},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_1","node_position":{"x":753,"y":116},"type":"uniform"},{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"name":"uniform_0","node_position":{"x":540,"y":234},"type":"uniform"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0.515625},{"b":0,"g":0,"pos":0.145455,"r":0.25},{"b":0,"g":0,"pos":0.445455,"r":0.515625},{"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"b":0,"g":0,"pos":1,"r":0.322917}],"name":"colorize_2","node_position":{"x":454.633789,"y":-189.5},"type":"colorize"},{"gradient":[{"b":0.034912,"g":0.129532,"pos":0,"r":0.203125},{"b":0.038791,"g":0.074319,"pos":1,"r":0.114583}],"name":"colorize_1","node_position":{"x":461.329102,"y":-116.699997},"type":"colorize"},{"name":"export_0","node_position":{"x":1090.329102,"y":-76.5},"resolution":1,"suffix":"mr","type":"export"},{"name":"combine_0","node_position":{"x":942.329102,"y":-55.5},"type":"combine"},{"iterations":6,"name":"perlin_0","node_position":{"x":12,"y":243.5},"persistence":0.7,"scale_x":20,"scale_y":3,"type":"perlin"}]}
|
{"connections":[{"from":"bricks_0","from_port":0,"to":"blend_0","to_port":0},{"from":"perlin_0","from_port":0,"to":"blend_0","to_port":1},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"perlin_1","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_1","to_port":1},{"from":"perlin_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_1","to_port":2},{"from":"blend_1","from_port":0,"to":"Material","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_2","to_port":0},{"from":"blend_2","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"normal_map_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"blend_2","to_port":1},{"from":"perlin_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_2","from_port":0,"to":"combine_0","to_port":1},{"from":"colorize_2","from_port":0,"to":"blend_1","to_port":0}],"nodes":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":938,"y":96},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"gradient":{"points":[{"b":0,"g":0,"pos":0.518182,"r":0},{"b":1,"g":1,"pos":0.709091,"r":1}],"type":"Gradient"},"name":"colorize_3","node_position":{"x":487.633789,"y":65},"type":"colorize"},{"bevel":0,"columns":5,"mortar":0.02,"name":"bricks_0","node_position":{"x":-1,"y":30.5},"pattern":0,"repeat":1,"row_offset":0.5,"rows":1,"type":"bricks"},{"gradient":{"points":[{"b":0,"g":0.336914,"pos":0,"r":0.598958},{"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"b":0,"g":0.357422,"pos":1,"r":0.635417}],"type":"Gradient"},"name":"colorize_0","node_position":{"x":472,"y":-41.5},"type":"colorize"},{"iterations":7,"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"persistence":0.55,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.4,"blend_type":0,"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"type":"blend"},{"iterations":6,"name":"perlin_2","node_position":{"x":232.633789,"y":40},"persistence":0.65,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.15,"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"size":2,"type":"normal_map"},{"amount":0.5,"blend_type":0,"name":"blend_1","node_position":{"x":707.633789,"y":-68},"type":"blend"},{"amount":1,"blend_type":2,"name":"blend_0","node_position":{"x":271,"y":306.5},"type":"blend"},{"gradient":{"points":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"type":"Gradient"},"name":"colorize_5","node_position":{"x":503,"y":336.5},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_1","node_position":{"x":753,"y":116},"type":"uniform"},{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"name":"uniform_0","node_position":{"x":540,"y":234},"type":"uniform"},{"gradient":{"points":[{"b":0,"g":0,"pos":0,"r":0.515625},{"b":0,"g":0,"pos":0.145455,"r":0.25},{"b":0,"g":0,"pos":0.445455,"r":0.515625},{"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"b":0,"g":0,"pos":1,"r":0.322917}],"type":"Gradient"},"name":"colorize_2","node_position":{"x":454.633789,"y":-189.5},"type":"colorize"},{"gradient":{"points":[{"b":0.034912,"g":0.129532,"pos":0,"r":0.203125},{"b":0.038791,"g":0.074319,"pos":1,"r":0.114583}],"type":"Gradient"},"name":"colorize_1","node_position":{"x":461.329102,"y":-116.699997},"type":"colorize"},{"name":"export_0","node_position":{"x":1090.329102,"y":-76.5},"resolution":1,"suffix":"mr","type":"export"},{"name":"combine_0","node_position":{"x":942.329102,"y":-55.5},"type":"combine"},{"iterations":6,"name":"perlin_0","node_position":{"x":12,"y":243.5},"persistence":0.7,"scale_x":20,"scale_y":3,"type":"perlin"}]}
|
@ -1 +1 @@
|
|||||||
{"connections":[{"from":"bricks_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"blend_0","from_port":0,"to":"Material","to_port":2},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"blend_0","from_port":0,"to":"transform_0","to_port":0},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_0","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"transform_1","from_port":0,"to":"blend_0","to_port":1},{"from":"perlin_0","from_port":0,"to":"transform_1","to_port":0},{"from":"bricks_0","from_port":1,"to":"decompose_0","to_port":0},{"from":"decompose_0","from_port":0,"to":"transform_1","to_port":1},{"from":"decompose_0","from_port":1,"to":"transform_1","to_port":2}],"nodes":[{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":0.213623,"g":0.391325,"pos":0.145455,"r":0.651042}],"name":"colorize_0","node_position":{"x":524,"y":-100.75},"type":"colorize"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":740,"y":135.25},"type":"normal_map"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_1","node_position":{"x":710,"y":208.25},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":718,"y":73},"type":"uniform"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":930,"y":38},"normal_scale":1,"roughness":1,"type":"material"},{"name":"combine_0","node_position":{"x":866,"y":-78},"type":"combine"},{"name":"export_0","node_position":{"x":1053,"y":-62},"suffix":"mr","type":"export"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":535,"y":2.25},"type":"blend"},{"name":"transform_0","node_position":{"x":527,"y":115},"repeat":true,"rotate":90,"scale_x":1,"scale_y":1,"translate_x":0,"translate_y":0,"type":"transform"},{"iterations":7,"name":"perlin_0","node_position":{"x":69,"y":81.25},"persistence":0.75,"scale_x":4,"scale_y":20,"type":"perlin"},{"name":"decompose_0","node_position":{"x":97,"y":236},"type":"decompose"},{"bevel":0,"columns":1,"mortar":0.02,"name":"bricks_0","node_position":{"x":79,"y":-124.75},"pattern":0,"repeat":1,"row_offset":0.5,"rows":10,"type":"bricks"},{"name":"transform_1","node_position":{"x":290,"y":120},"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":1,"translate_y":1,"type":"transform"}]}
|
{"connections":[{"from":"bricks_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"blend_0","from_port":0,"to":"Material","to_port":2},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_0","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"transform_1","from_port":0,"to":"blend_0","to_port":1},{"from":"perlin_0","from_port":0,"to":"transform_1","to_port":0},{"from":"bricks_0","from_port":1,"to":"decompose_0","to_port":0},{"from":"decompose_0","from_port":0,"to":"transform_1","to_port":1},{"from":"decompose_0","from_port":1,"to":"transform_1","to_port":2}],"nodes":[{"gradient":{"points":[{"b":0,"g":0,"pos":0,"r":0},{"b":0.213623,"g":0.391325,"pos":0.145455,"r":0.651042}],"type":"Gradient"},"name":"colorize_0","node_position":{"x":524,"y":-100.75},"type":"colorize"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":740,"y":135.25},"size":2,"type":"normal_map"},{"gradient":{"points":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"type":"Gradient"},"name":"colorize_1","node_position":{"x":710,"y":208.25},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":718,"y":73},"type":"uniform"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":930,"y":38},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"name":"combine_0","node_position":{"x":866,"y":-78},"type":"combine"},{"name":"export_0","node_position":{"x":1053,"y":-62},"resolution":1,"suffix":"mr","type":"export"},{"iterations":7,"name":"perlin_0","node_position":{"x":69,"y":81.25},"persistence":0.75,"scale_x":4,"scale_y":20,"type":"perlin"},{"name":"decompose_0","node_position":{"x":97,"y":236},"type":"decompose"},{"bevel":0,"columns":1,"mortar":0.02,"name":"bricks_0","node_position":{"x":79,"y":-124.75},"pattern":0,"repeat":1,"row_offset":0.5,"rows":10,"type":"bricks"},{"name":"transform_1","node_position":{"x":290,"y":120},"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":1,"translate_y":1,"type":"transform"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":535,"y":2.25},"type":"blend"}]}
|
@ -2,6 +2,7 @@ tool
|
|||||||
extends GraphEdit
|
extends GraphEdit
|
||||||
|
|
||||||
var editor_interface = null
|
var editor_interface = null
|
||||||
|
var node_factory = null
|
||||||
var renderer = null
|
var renderer = null
|
||||||
|
|
||||||
var save_path = null
|
var save_path = null
|
||||||
@ -116,14 +117,7 @@ func create_nodes(data, position = null):
|
|||||||
if data == null:
|
if data == null:
|
||||||
return
|
return
|
||||||
if data.has("type"):
|
if data.has("type"):
|
||||||
var node = null
|
var node = node_factory.create_node(data.type)
|
||||||
if File.new().file_exists("res://addons/material_maker/nodes/"+data.type+".mmn"):
|
|
||||||
node = preload("res://addons/material_maker/nodes/node_generic.gd").new()
|
|
||||||
node.model = data.type
|
|
||||||
else:
|
|
||||||
var node_type = load("res://addons/material_maker/nodes/"+data.type+"/"+data.type+".tscn")
|
|
||||||
if node_type != null:
|
|
||||||
node = node_type.instance()
|
|
||||||
if node != null:
|
if node != null:
|
||||||
if data.has("name") && !has_node(data.name):
|
if data.has("name") && !has_node(data.name):
|
||||||
node.name = data.name
|
node.name = data.name
|
||||||
|
@ -80,6 +80,7 @@ func menu_about_to_show(name, menu):
|
|||||||
|
|
||||||
func new_pane():
|
func new_pane():
|
||||||
var graph_edit = preload("res://addons/material_maker/graph_edit.tscn").instance()
|
var graph_edit = preload("res://addons/material_maker/graph_edit.tscn").instance()
|
||||||
|
graph_edit.node_factory = $NodeFactory
|
||||||
graph_edit.renderer = $Renderer
|
graph_edit.renderer = $Renderer
|
||||||
graph_edit.editor_interface = editor_interface
|
graph_edit.editor_interface = editor_interface
|
||||||
$VBoxContainer/HBoxContainer/Projects.add_child(graph_edit)
|
$VBoxContainer/HBoxContainer/Projects.add_child(graph_edit)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/main_window.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/main_window.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/material_maker/library.gd" type="Script" id=2]
|
[ext_resource path="res://addons/material_maker/library.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://addons/material_maker/preview.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://addons/material_maker/preview.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=4]
|
[ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6]
|
||||||
|
|
||||||
[node name="MainWindow" type="Panel"]
|
[node name="MainWindow" type="Panel" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -262,6 +263,10 @@ scrolling_enabled = true
|
|||||||
|
|
||||||
[node name="Renderer" parent="." index="1" instance=ExtResource( 5 )]
|
[node name="Renderer" parent="." index="1" instance=ExtResource( 5 )]
|
||||||
|
|
||||||
|
[node name="NodeFactory" type="Node" parent="." index="2"]
|
||||||
|
|
||||||
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/Projects" to="." method="new_material"]
|
[connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/Projects" to="." method="new_material"]
|
||||||
|
|
||||||
[connection signal="resized" from="VBoxContainer/HBoxContainer/Projects" to="VBoxContainer/HBoxContainer/Projects" method="_on_Projects_resized"]
|
[connection signal="resized" from="VBoxContainer/HBoxContainer/Projects" to="VBoxContainer/HBoxContainer/Projects" method="_on_Projects_resized"]
|
||||||
|
@ -11,7 +11,10 @@ class OutPort:
|
|||||||
|
|
||||||
func generate_shader():
|
func generate_shader():
|
||||||
return node.generate_shader(port)
|
return node.generate_shader(port)
|
||||||
|
|
||||||
|
func get_globals():
|
||||||
|
return node.get_globals()
|
||||||
|
|
||||||
func get_textures():
|
func get_textures():
|
||||||
return node.get_textures()
|
return node.get_textures()
|
||||||
|
|
||||||
@ -111,10 +114,10 @@ func get_source(index = 0):
|
|||||||
|
|
||||||
func get_source_f(source):
|
func get_source_f(source):
|
||||||
var rv
|
var rv
|
||||||
if source.has("rgb"):
|
if source.has("f"):
|
||||||
rv = "dot("+source.rgb+", vec3(1.0))/3.0"
|
|
||||||
elif source.has("f"):
|
|
||||||
rv = source.f
|
rv = source.f
|
||||||
|
elif source.has("rgb"):
|
||||||
|
rv = "dot("+source.rgb+", vec3(1.0))/3.0"
|
||||||
else:
|
else:
|
||||||
rv = "***error***"
|
rv = "***error***"
|
||||||
return rv
|
return rv
|
||||||
@ -151,6 +154,22 @@ func get_shader_code(uv, slot = 0):
|
|||||||
rv.f = "vec3(0.0)"
|
rv.f = "vec3(0.0)"
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
func get_shader_code_with_globals(uv, slot = 0):
|
||||||
|
var code = get_shader_code(uv, slot)
|
||||||
|
code.globals = get_globals()
|
||||||
|
return code
|
||||||
|
|
||||||
|
func get_globals():
|
||||||
|
var list = []
|
||||||
|
for i in range(get_connection_input_count()):
|
||||||
|
var source = get_source(i)
|
||||||
|
if source != null:
|
||||||
|
var source_list = source.get_globals()
|
||||||
|
for g in source_list:
|
||||||
|
if list.find(g) == -1:
|
||||||
|
list.append(g)
|
||||||
|
return list
|
||||||
|
|
||||||
func get_textures():
|
func get_textures():
|
||||||
var list = {}
|
var list = {}
|
||||||
for i in range(get_connection_input_count()):
|
for i in range(get_connection_input_count()):
|
||||||
@ -181,7 +200,7 @@ func generate_shader(slot = 0):
|
|||||||
for c in get_parent().get_children():
|
for c in get_parent().get_children():
|
||||||
if c is GraphNode:
|
if c is GraphNode:
|
||||||
c.reset()
|
c.reset()
|
||||||
return get_parent().renderer.generate_shader(get_shader_code("UV", slot))
|
return get_parent().renderer.generate_shader(get_shader_code_with_globals("UV", slot))
|
||||||
|
|
||||||
func serialize():
|
func serialize():
|
||||||
var type = get_script().resource_path
|
var type = get_script().resource_path
|
||||||
|
18
addons/material_maker/node_factory.gd
Normal file
18
addons/material_maker/node_factory.gd
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
tool
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var includes
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func create_node(type):
|
||||||
|
var node = null
|
||||||
|
if File.new().file_exists("res://addons/material_maker/nodes/"+type+".mmn"):
|
||||||
|
node = preload("res://addons/material_maker/nodes/node_generic.gd").new()
|
||||||
|
node.model = type
|
||||||
|
else:
|
||||||
|
var node_type = load("res://addons/material_maker/nodes/"+type+"/"+type+".tscn")
|
||||||
|
if node_type != null:
|
||||||
|
node = node_type.instance()
|
||||||
|
return node
|
@ -68,7 +68,7 @@ func _get_shader_code(uv):
|
|||||||
var src = get_source()
|
var src = get_source()
|
||||||
if src == null:
|
if src == null:
|
||||||
return rv
|
return rv
|
||||||
input_shader = get_parent().renderer.generate_shader(src.get_shader_code("UV"))
|
input_shader = get_parent().renderer.generate_shader(src.get_shader_code_with_globals("UV"))
|
||||||
_rerender()
|
_rerender()
|
||||||
if generated_variants.empty():
|
if generated_variants.empty():
|
||||||
rv.defs = "uniform sampler2D "+name+"_tex;\n"
|
rv.defs = "uniform sampler2D "+name+"_tex;\n"
|
||||||
|
@ -6,7 +6,7 @@ const OUTPUTS = [ "r", "g", "b" ]
|
|||||||
func _get_shader_code(uv, output = 0):
|
func _get_shader_code(uv, output = 0):
|
||||||
var rv = { defs="", code="" }
|
var rv = { defs="", code="" }
|
||||||
var src = get_source()
|
var src = get_source()
|
||||||
var src_code = { defs="", code="", rgb="vec3(0.0)" }
|
var src_code = { defs="", code="", f="0.0" }
|
||||||
if src != null:
|
if src != null:
|
||||||
src_code = src.get_shader_code(uv)
|
src_code = src.get_shader_code(uv)
|
||||||
if generated_variants.empty():
|
if generated_variants.empty():
|
||||||
|
@ -50,7 +50,7 @@ func _get_shader_code(uv):
|
|||||||
var src = get_source()
|
var src = get_source()
|
||||||
if src == null:
|
if src == null:
|
||||||
return rv
|
return rv
|
||||||
input_shader = get_parent().generate_shader(src.get_shader_code("UV"))
|
input_shader = get_parent().generate_shader(src.get_shader_code_get_globals("UV"))
|
||||||
_rerender()
|
_rerender()
|
||||||
if generated_variants.empty():
|
if generated_variants.empty():
|
||||||
rv.defs = "uniform sampler2D %s_tex;\n" % [ name ]
|
rv.defs = "uniform sampler2D %s_tex;\n" % [ name ]
|
||||||
|
@ -81,7 +81,7 @@ func update_materials(material_list):
|
|||||||
var source_code = [ null, null, null ]
|
var source_code = [ null, null, null ]
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
if source[i] != null:
|
if source[i] != null:
|
||||||
source_code[i] = source[i].get_shader_code("UV")
|
source_code[i] = source[i].get_shader_code_with_globals("UV")
|
||||||
else:
|
else:
|
||||||
source_code[i] = { defs="", code="", f=t.default_values[i] }
|
source_code[i] = { defs="", code="", f=t.default_values[i] }
|
||||||
shader = get_parent().renderer.generate_combined_shader(source_code[0], source_code[1], source_code[2])
|
shader = get_parent().renderer.generate_combined_shader(source_code[0], source_code[1], source_code[2])
|
||||||
|
@ -27,6 +27,8 @@ func set_model(m):
|
|||||||
data = parse_json(data)
|
data = parse_json(data)
|
||||||
model = m
|
model = m
|
||||||
update_node(data)
|
update_node(data)
|
||||||
|
else:
|
||||||
|
print("set_model error "+str(m))
|
||||||
|
|
||||||
func update_node(data):
|
func update_node(data):
|
||||||
if typeof(data) != TYPE_DICTIONARY:
|
if typeof(data) != TYPE_DICTIONARY:
|
||||||
@ -66,10 +68,10 @@ func update_node(data):
|
|||||||
parameters[p.name] = 0.5*(p.min+p.max)
|
parameters[p.name] = 0.5*(p.min+p.max)
|
||||||
elif p.type == "size":
|
elif p.type == "size":
|
||||||
control = OptionButton.new()
|
control = OptionButton.new()
|
||||||
for i in range(p.first, p.last):
|
for i in range(p.first, p.last+1):
|
||||||
var s = pow(2, i)
|
var s = pow(2, i)
|
||||||
control.add_item("%dx%d" % [ s, s ])
|
control.add_item("%dx%d" % [ s, s ])
|
||||||
control.selected = 0 if !p.has("default") else p.default
|
control.selected = 0 if !p.has("default") else p.default-p.first
|
||||||
elif p.type == "enum":
|
elif p.type == "enum":
|
||||||
control = OptionButton.new()
|
control = OptionButton.new()
|
||||||
for i in p.values.size():
|
for i in p.values.size():
|
||||||
@ -133,25 +135,32 @@ func subst(string, uv = ""):
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
func _get_shader_code(uv, slot = 0):
|
func _get_shader_code(uv, slot = 0):
|
||||||
var rv = { defs="", code="", f="0.0" }
|
var rv = { defs="", code="" }
|
||||||
|
var variant_string = uv+","+str(slot)
|
||||||
if model_data != null and model_data.has("outputs") and model_data.outputs.size() > slot:
|
if model_data != null and model_data.has("outputs") and model_data.outputs.size() > slot:
|
||||||
var output = model_data.outputs[slot]
|
var output = model_data.outputs[slot]
|
||||||
if model_data.has("instance") && generated_variants.empty():
|
if model_data.has("instance") && generated_variants.empty():
|
||||||
rv.defs = subst(model_data.instance)
|
rv.defs = subst(model_data.instance)
|
||||||
var variant_index = generated_variants.find(uv)
|
var variant_index = generated_variants.find(variant_string)
|
||||||
if variant_index == -1:
|
if variant_index == -1:
|
||||||
variant_index = generated_variants.size()
|
variant_index = generated_variants.size()
|
||||||
generated_variants.append(uv)
|
generated_variants.append(variant_string)
|
||||||
if output.has("rgb"):
|
if output.has("rgb"):
|
||||||
rv.code += "vec3 %s_%d_rgb = %s;\n" % [ name, variant_index, subst(output.rgb, uv) ]
|
rv.code += "vec3 %s_%d_%d_rgb = %s;\n" % [ name, slot, variant_index, subst(output.rgb, uv) ]
|
||||||
if output.has("f"):
|
if output.has("f"):
|
||||||
rv.code += "float %s_%d_f = %s;\n" % [ name, variant_index, subst(output.f, uv) ]
|
rv.code += "float %s_%d_%d_f = %s;\n" % [ name, slot, variant_index, subst(output.f, uv) ]
|
||||||
if output.has("rgb"):
|
if output.has("rgb"):
|
||||||
rv.rgb = "%s_%d_rgb" % [ name, variant_index ]
|
rv.rgb = "%s_%d_%d_rgb" % [ name, slot, variant_index ]
|
||||||
if output.has("f"):
|
if output.has("f"):
|
||||||
rv.f = "%s_%d_f" % [ name, variant_index ]
|
rv.f = "%s_%d_%d_f" % [ name, slot, variant_index ]
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
func get_globals():
|
||||||
|
var list = .get_globals()
|
||||||
|
if model_data.has("global") and list.find(model_data.global) == -1:
|
||||||
|
list.append(model_data.global)
|
||||||
|
return list
|
||||||
|
|
||||||
func _on_offset_changed():
|
func _on_offset_changed():
|
||||||
update_shaders()
|
update_shaders()
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func _get_shader_code(uv):
|
|||||||
var src = get_source()
|
var src = get_source()
|
||||||
if src == null:
|
if src == null:
|
||||||
return rv
|
return rv
|
||||||
input_shader = get_parent().renderer.generate_shader(src.get_shader_code("UV"))
|
input_shader = get_parent().renderer.generate_shader(src.get_shader_code_with_globals("UV"))
|
||||||
_rerender()
|
_rerender()
|
||||||
if generated_variants.empty():
|
if generated_variants.empty():
|
||||||
rv.defs = "uniform sampler2D %s_tex;\n" % [ name ]
|
rv.defs = "uniform sampler2D %s_tex;\n" % [ name ]
|
||||||
|
@ -340,7 +340,7 @@ _sections_unfolded = [ "GUI", "Render Target" ]
|
|||||||
|
|
||||||
[node name="Objects" type="Spatial" parent="MaterialPreview" index="0"]
|
[node name="Objects" type="Spatial" parent="MaterialPreview" index="0"]
|
||||||
|
|
||||||
transform = Transform( -0.407451, 0, -0.913223, 0, 1, 0, 0.913223, 0, -0.407451, 0, 0, 0 )
|
transform = Transform( 0.999464, 0, 0.0326148, 0, 1, 0, -0.0326148, 0, 0.999464, 0, 0, 0 )
|
||||||
_sections_unfolded = [ "Transform" ]
|
_sections_unfolded = [ "Transform" ]
|
||||||
|
|
||||||
[node name="Cube" type="MeshInstance" parent="MaterialPreview/Objects" index="0"]
|
[node name="Cube" type="MeshInstance" parent="MaterialPreview/Objects" index="0"]
|
||||||
|
@ -15,6 +15,9 @@ static func generate_shader(src_code):
|
|||||||
file.open("res://addons/material_maker/common.shader", File.READ)
|
file.open("res://addons/material_maker/common.shader", File.READ)
|
||||||
code += file.get_as_text()
|
code += file.get_as_text()
|
||||||
code += "\n"
|
code += "\n"
|
||||||
|
if src_code.has("globals"):
|
||||||
|
for g in src_code.globals:
|
||||||
|
code += g
|
||||||
var shader_code = src_code.defs
|
var shader_code = src_code.defs
|
||||||
shader_code += "void fragment() {\n"
|
shader_code += "void fragment() {\n"
|
||||||
shader_code += src_code.code
|
shader_code += src_code.code
|
||||||
@ -31,6 +34,15 @@ static func generate_combined_shader(red_code, green_code, blue_code):
|
|||||||
file.open("res://addons/material_maker/common.shader", File.READ)
|
file.open("res://addons/material_maker/common.shader", File.READ)
|
||||||
code += file.get_as_text()
|
code += file.get_as_text()
|
||||||
code += "\n"
|
code += "\n"
|
||||||
|
if red_code.has("globals"):
|
||||||
|
for g in red_code.globals:
|
||||||
|
code += g
|
||||||
|
if green_code.has("globals"):
|
||||||
|
for g in green_code.globals:
|
||||||
|
code += g
|
||||||
|
if blue_code.has("globals"):
|
||||||
|
for g in blue_code.globals:
|
||||||
|
code += g
|
||||||
var shader_code = ""
|
var shader_code = ""
|
||||||
shader_code += red_code.defs
|
shader_code += red_code.defs
|
||||||
shader_code += green_code.defs
|
shader_code += green_code.defs
|
||||||
@ -72,7 +84,7 @@ func render_shader_to_viewport(shader, textures, render_size, method, args):
|
|||||||
render_queue.pop_front()
|
render_queue.pop_front()
|
||||||
|
|
||||||
func render_to_viewport(node, render_size, method, args):
|
func render_to_viewport(node, render_size, method, args):
|
||||||
render_shader_to_viewport(node.generate_shader(), node.get_textures(), render_size, method, args)
|
render_shader_to_viewport(node.generate_shader_with_globals(), node.get_textures(), render_size, method, args)
|
||||||
|
|
||||||
func export_texture(node, filename, render_size = 256):
|
func export_texture(node, filename, render_size = 256):
|
||||||
if node == null:
|
if node == null:
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
[ext_resource path="res://addons/material_maker/widgets/node_editor/node_editor.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/widgets/node_editor/node_editor.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/material_maker/icons/plus.png" type="Texture" id=2]
|
[ext_resource path="res://addons/material_maker/icons/plus.png" type="Texture" id=2]
|
||||||
|
|
||||||
[node name="NodeEditor" type="WindowDialog"]
|
[node name="NodeEditor" type="WindowDialog" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 726.0
|
margin_right = 833.0
|
||||||
margin_bottom = 399.0
|
margin_bottom = 398.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -44,8 +44,8 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 726.0
|
margin_right = 833.0
|
||||||
margin_bottom = 375.0
|
margin_bottom = 374.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -80,7 +80,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -119,7 +119,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 46.0
|
margin_left = 46.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -143,7 +143,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 28.0
|
margin_top = 28.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 42.0
|
margin_bottom = 42.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -164,7 +164,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 46.0
|
margin_top = 46.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 181.0
|
margin_bottom = 181.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = true
|
rect_clip_content = true
|
||||||
@ -185,7 +185,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 22.0
|
margin_bottom = 22.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -313,7 +313,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 185.0
|
margin_top = 185.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 199.0
|
margin_bottom = 199.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -334,8 +334,8 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_top = 203.0
|
margin_top = 203.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 339.0
|
margin_bottom = 338.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = true
|
rect_clip_content = true
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
@ -355,7 +355,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 718.0
|
margin_right = 825.0
|
||||||
margin_bottom = 22.0
|
margin_bottom = 22.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -466,10 +466,10 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 291.0
|
margin_left = 344.0
|
||||||
margin_top = 379.0
|
margin_top = 378.0
|
||||||
margin_right = 435.0
|
margin_right = 488.0
|
||||||
margin_bottom = 399.0
|
margin_bottom = 398.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
@ -1,11 +1,40 @@
|
|||||||
tool
|
tool
|
||||||
extends HBoxContainer
|
extends HBoxContainer
|
||||||
|
|
||||||
|
var size_first = 0
|
||||||
|
var size_last = 12
|
||||||
|
var size_default = 8
|
||||||
|
|
||||||
const PARAMETER_TYPE = [ "float", "size", "enum", "boolean" ]
|
const PARAMETER_TYPE = [ "float", "size", "enum", "boolean" ]
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Parameter of type SIZE
|
||||||
|
|
||||||
|
func update_size_option_button(button, first, last, current):
|
||||||
|
button.clear()
|
||||||
|
for i in range(first, last+1):
|
||||||
|
var s = pow(2, i)
|
||||||
|
button.add_item("%dx%d" % [ s, s ])
|
||||||
|
button.selected = current - first
|
||||||
|
|
||||||
|
func update_size_configuration():
|
||||||
|
update_size_option_button($Types/T1/First, 0, size_last, size_first)
|
||||||
|
update_size_option_button($Types/T1/Last, size_first, 12, size_last)
|
||||||
|
update_size_option_button($Types/T1/Default, size_first, size_last, size_default)
|
||||||
|
|
||||||
|
func _on_First_item_selected(ID):
|
||||||
|
size_first = ID
|
||||||
|
update_size_configuration()
|
||||||
|
|
||||||
|
func _on_Last_item_selected(ID):
|
||||||
|
size_last = size_first + ID
|
||||||
|
update_size_configuration()
|
||||||
|
|
||||||
|
func _on_Default_item_selected(ID):
|
||||||
|
size_default = size_first + ID
|
||||||
|
|
||||||
func set_model_data(data):
|
func set_model_data(data):
|
||||||
if data.has("name"):
|
if data.has("name"):
|
||||||
$Name.text = data.name
|
$Name.text = data.name
|
||||||
@ -29,6 +58,11 @@ func set_model_data(data):
|
|||||||
elif data.type == "size":
|
elif data.type == "size":
|
||||||
$Type.selected = 1
|
$Type.selected = 1
|
||||||
w = $Types/T1
|
w = $Types/T1
|
||||||
|
if data.has("first"):
|
||||||
|
size_first = data.first
|
||||||
|
if data.has("last"):
|
||||||
|
size_last = data.last
|
||||||
|
update_size_configuration()
|
||||||
elif data.type == "enum":
|
elif data.type == "enum":
|
||||||
$Type.selected = 2
|
$Type.selected = 2
|
||||||
w = $Types/T2
|
w = $Types/T2
|
||||||
@ -50,6 +84,10 @@ func get_model_data():
|
|||||||
data.step = $Types/T0/Step.value
|
data.step = $Types/T0/Step.value
|
||||||
if $Types/T0/SpinBox.pressed:
|
if $Types/T0/SpinBox.pressed:
|
||||||
data.widget = "spinbox"
|
data.widget = "spinbox"
|
||||||
|
elif $Type.selected == 1:
|
||||||
|
data.first = size_first
|
||||||
|
data.last = size_last
|
||||||
|
data.default = size_default
|
||||||
return data
|
return data
|
||||||
|
|
||||||
func _on_Delete_pressed():
|
func _on_Delete_pressed():
|
||||||
@ -58,3 +96,4 @@ func _on_Delete_pressed():
|
|||||||
func _on_OptionButton_item_selected(ID):
|
func _on_OptionButton_item_selected(ID):
|
||||||
for c in $Types.get_children():
|
for c in $Types.get_children():
|
||||||
c.visible = "T"+str(ID) == c.name
|
c.visible = "T"+str(ID) == c.name
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ anchor_top = 0.0
|
|||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 254.0
|
margin_left = 254.0
|
||||||
margin_right = 669.0
|
margin_right = 801.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -146,7 +146,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 415.0
|
margin_right = 547.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -297,14 +297,61 @@ editable = true
|
|||||||
prefix = ""
|
prefix = ""
|
||||||
suffix = ""
|
suffix = ""
|
||||||
|
|
||||||
[node name="SpinBox" type="CheckBox" parent="Types/T0" index="6"]
|
[node name="LabelDefault" type="Label" parent="Types/T0" index="6"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 336.0
|
margin_left = 336.0
|
||||||
margin_right = 415.0
|
margin_top = 5.0
|
||||||
|
margin_right = 386.0
|
||||||
|
margin_bottom = 19.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 4
|
||||||
|
text = "Default:"
|
||||||
|
percent_visible = 1.0
|
||||||
|
lines_skipped = 0
|
||||||
|
max_lines_visible = -1
|
||||||
|
|
||||||
|
[node name="Default" type="SpinBox" parent="Types/T0" index="7"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 390.0
|
||||||
|
margin_right = 464.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
min_value = 0.0
|
||||||
|
max_value = 65535.0
|
||||||
|
step = 0.0
|
||||||
|
page = 0.0
|
||||||
|
value = 0.0
|
||||||
|
exp_edit = false
|
||||||
|
rounded = false
|
||||||
|
editable = true
|
||||||
|
prefix = ""
|
||||||
|
suffix = ""
|
||||||
|
|
||||||
|
[node name="SpinBox" type="CheckBox" parent="Types/T0" index="8"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 468.0
|
||||||
|
margin_right = 547.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -323,7 +370,6 @@ align = 0
|
|||||||
|
|
||||||
[node name="T1" type="HBoxContainer" parent="Types" index="1"]
|
[node name="T1" type="HBoxContainer" parent="Types" index="1"]
|
||||||
|
|
||||||
editor/display_folded = true
|
|
||||||
visible = false
|
visible = false
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -339,7 +385,7 @@ size_flags_horizontal = 1
|
|||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="LabelMin" type="Label" parent="Types/T1" index="0"]
|
[node name="LabelFirst" type="Label" parent="Types/T1" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -359,7 +405,7 @@ percent_visible = 1.0
|
|||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
|
|
||||||
[node name="Min" type="OptionButton" parent="Types/T1" index="1"]
|
[node name="First" type="OptionButton" parent="Types/T1" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -385,7 +431,7 @@ align = 0
|
|||||||
items = [ ]
|
items = [ ]
|
||||||
selected = -1
|
selected = -1
|
||||||
|
|
||||||
[node name="LabelMax" type="Label" parent="Types/T1" index="2"]
|
[node name="LabelLast" type="Label" parent="Types/T1" index="2"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -406,7 +452,7 @@ percent_visible = 1.0
|
|||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
|
|
||||||
[node name="Max" type="OptionButton" parent="Types/T1" index="3"]
|
[node name="Last" type="OptionButton" parent="Types/T1" index="3"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -432,6 +478,53 @@ align = 0
|
|||||||
items = [ ]
|
items = [ ]
|
||||||
selected = -1
|
selected = -1
|
||||||
|
|
||||||
|
[node name="LabelDefault" type="Label" parent="Types/T1" index="4"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 551.0
|
||||||
|
margin_top = 5.0
|
||||||
|
margin_right = 581.0
|
||||||
|
margin_bottom = 19.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 4
|
||||||
|
text = "Default:"
|
||||||
|
percent_visible = 1.0
|
||||||
|
lines_skipped = 0
|
||||||
|
max_lines_visible = -1
|
||||||
|
|
||||||
|
[node name="Default" type="OptionButton" parent="Types/T1" index="5"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 585.0
|
||||||
|
margin_right = 624.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
toggle_mode = false
|
||||||
|
action_mode = 0
|
||||||
|
enabled_focus_mode = 2
|
||||||
|
shortcut = null
|
||||||
|
group = null
|
||||||
|
flat = false
|
||||||
|
align = 0
|
||||||
|
items = [ ]
|
||||||
|
selected = -1
|
||||||
|
|
||||||
[node name="T2" type="HBoxContainer" parent="Types" index="2"]
|
[node name="T2" type="HBoxContainer" parent="Types" index="2"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
@ -477,11 +570,13 @@ selected = -1
|
|||||||
|
|
||||||
[node name="T3" type="HBoxContainer" parent="Types" index="3"]
|
[node name="T3" type="HBoxContainer" parent="Types" index="3"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
visible = false
|
visible = false
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
|
margin_right = 74.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -491,8 +586,37 @@ size_flags_horizontal = 1
|
|||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
|
[node name="Default" type="CheckBox" parent="Types/T3" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_right = 74.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
toggle_mode = true
|
||||||
|
enabled_focus_mode = 2
|
||||||
|
shortcut = null
|
||||||
|
group = null
|
||||||
|
text = "Default"
|
||||||
|
flat = false
|
||||||
|
align = 0
|
||||||
|
|
||||||
[connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]
|
[connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]
|
||||||
|
|
||||||
[connection signal="item_selected" from="Type" to="." method="_on_OptionButton_item_selected"]
|
[connection signal="item_selected" from="Type" to="." method="_on_OptionButton_item_selected"]
|
||||||
|
|
||||||
|
[connection signal="item_selected" from="Types/T1/First" to="." method="_on_First_item_selected"]
|
||||||
|
|
||||||
|
[connection signal="item_selected" from="Types/T1/Last" to="." method="_on_Last_item_selected"]
|
||||||
|
|
||||||
|
[connection signal="item_selected" from="Types/T1/Default" to="." method="_on_Default_item_selected"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,20 +35,17 @@ func move_active_tab_to(idx_to):
|
|||||||
set_current_tab(idx_to)
|
set_current_tab(idx_to)
|
||||||
|
|
||||||
func set_current_tab(t):
|
func set_current_tab(t):
|
||||||
if t == current_tab:
|
if t == current_tab or t < 0 or t >= $Tabs.get_tab_count():
|
||||||
return
|
return
|
||||||
var node
|
var node
|
||||||
if current_tab >= 0 && current_tab < $Tabs.get_tab_count():
|
if current_tab >= 0 && current_tab < $Tabs.get_tab_count():
|
||||||
node = get_child(current_tab)
|
node = get_child(current_tab)
|
||||||
node.visible = false
|
node.visible = false
|
||||||
current_tab = t
|
current_tab = t
|
||||||
if current_tab >= 0 && current_tab < $Tabs.get_tab_count():
|
node = get_child(current_tab)
|
||||||
node = get_child(current_tab)
|
node.visible = true
|
||||||
node.visible = true
|
node.rect_position = Vector2(0, $Tabs.rect_size.y)
|
||||||
node.rect_position = Vector2(0, $Tabs.rect_size.y)
|
node.rect_size = rect_size - node.rect_position
|
||||||
node.rect_size = rect_size - node.rect_position
|
|
||||||
else:
|
|
||||||
print("Incorrect current tab "+str(current_tab))
|
|
||||||
$Tabs.current_tab = current_tab
|
$Tabs.current_tab = current_tab
|
||||||
emit_signal("tab_changed", current_tab)
|
emit_signal("tab_changed", current_tab)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/main_window.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://addons/material_maker/main_window.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
[node name="WindowDialog" type="WindowDialog" index="0"]
|
[node name="WindowDialog" type="WindowDialog"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
|
@ -15,7 +15,7 @@ run/main_scene="res://addons/material_maker/main_window.tscn"
|
|||||||
config/use_custom_user_dir=true
|
config/use_custom_user_dir=true
|
||||||
config/custom_user_dir_name="material_maker"
|
config/custom_user_dir_name="material_maker"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
config/release="0.5"
|
config/release="0.6"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user