Added box and sphere node templates and an example

This commit is contained in:
RodZill4 2019-12-04 21:20:59 +01:00
parent ebeb998333
commit 8106811812
3 changed files with 816 additions and 0 deletions

View File

@ -0,0 +1,641 @@
{
"connections": [
{
"from": "graph",
"from_port": 0,
"to": "Material",
"to_port": 4
},
{
"from": "graph",
"from_port": 2,
"to": "Material",
"to_port": 6
},
{
"from": "graph",
"from_port": 1,
"to": "Material",
"to_port": 5
},
{
"from": "transform",
"from_port": 0,
"to": "blend",
"to_port": 0
},
{
"from": "blend",
"from_port": 0,
"to": "graph",
"to_port": 0
},
{
"from": "graph",
"from_port": 0,
"to": "edge_detect_1",
"to_port": 0
},
{
"from": "edge_detect_1",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "colorize",
"from_port": 0,
"to": "Material",
"to_port": 0
},
{
"from": "box",
"from_port": 0,
"to": "blend",
"to_port": 1
},
{
"from": "sphere",
"from_port": 0,
"to": "transform",
"to_port": 0
}
],
"label": "Graph",
"name": "49",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"name": "Material",
"node_position": {
"x": -165,
"y": 7
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao_light_affect": 1,
"depth_scale": 1,
"emission_energy": 1,
"metallic": 1,
"normal_scale": 1,
"roughness": 1,
"size": 11,
"subsurf_scatter_strength": 0
},
"type": "material"
},
{
"name": "transform",
"node_position": {
"x": -997.5,
"y": -141
},
"parameters": {
"repeat": true,
"rotate": 0,
"scale_x": 0.5,
"scale_y": 0.5,
"translate_x": 0.25,
"translate_y": 0.25
},
"type": "transform"
},
{
"connections": [
{
"from": "normal_map",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
},
{
"from": "colorize",
"from_port": 0,
"to": "gen_outputs",
"to_port": 2
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "normal_map",
"to_port": 0
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "occlusion",
"to_port": 0
},
{
"from": "occlusion",
"from_port": 0,
"to": "gen_outputs",
"to_port": 1
}
],
"label": "NOD",
"name": "graph",
"node_position": {
"x": -431.27063,
"y": 70.5
},
"nodes": [
{
"connections": [
{
"from": "nm_convolution",
"from_port": 0,
"to": "nm_postprocess",
"to_port": 0
},
{
"from": "nm_postprocess",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "buffer",
"to_port": 0
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "nm_convolution",
"to_port": 0
}
],
"label": "Normal Map",
"name": "normal_map",
"node_position": {
"x": -57.5,
"y": -41
},
"nodes": [
{
"name": "buffer",
"node_position": {
"x": -694.663818,
"y": 98.60614
},
"parameters": {
"lod": 0,
"size": 11
},
"type": "buffer"
},
{
"convolution_params": {
"input_type": "f",
"matrix": [
[
[
-1,
-1,
0
],
[
0,
-2,
0
],
[
1,
-1,
0
]
],
[
[
-2,
0,
0
],
0,
[
2,
0,
0
]
],
[
[
-1,
1,
0
],
[
0,
2,
0
],
[
1,
1,
0
]
]
],
"output_type": "rgb",
"x": 1,
"y": 1
},
"name": "nm_convolution",
"node_position": {
"x": -690.25,
"y": 174.25
},
"parameters": {
"size": 11
},
"type": "convolution"
},
{
"name": "nm_postprocess",
"node_position": {
"x": -690.25,
"y": 222.25
},
"parameters": {
"amount": 2,
"format": 0,
"size": 11,
"type": 0
},
"shader_model": {
"code": "",
"global": "vec3 process_normal_default(vec3 v, float multiplier) {\n\treturn 0.5*normalize(v.xyz*multiplier+vec3(0.0, 0.0, -1.0))+vec3(0.5);\n}\n\nvec3 process_normal_opengl(vec3 v, float multiplier) {\n\treturn 0.5*normalize(v.xyz*multiplier+vec3(0.0, 0.0, 1.0))+vec3(0.5);\n}\n\nvec3 process_normal_directx(vec3 v, float multiplier) {\n\treturn 0.5*normalize(v.xyz*vec3(1.0, -1.0, 1.0)*multiplier+vec3(0.0, 0.0, 1.0))+vec3(0.5);\n}\n",
"inputs": [
{
"default": "vec3(0.0)",
"label": "",
"name": "in",
"type": "rgb"
}
],
"instance": "",
"name": "NormalMapPostProcess",
"outputs": [
{
"rgb": "process_normal_$format($in($uv).xyz, $amount*$size/128.0)",
"type": "rgb"
}
],
"parameters": [
{
"default": 0,
"label": "",
"name": "format",
"type": "enum",
"values": [
{
"name": "Default",
"value": "default"
},
{
"name": "OpenGL",
"value": "opengl"
},
{
"name": "DirectX",
"value": "directx"
}
]
},
{
"default": 9,
"first": 4,
"label": "",
"last": 11,
"name": "size",
"type": "size"
},
{
"default": 1,
"label": "",
"max": 2,
"min": 0,
"name": "amount",
"step": 0.005,
"type": "float"
}
]
},
"type": "shader"
},
{
"name": "gen_parameters",
"node_position": {
"x": -698.910156,
"y": -42.916687
},
"parameters": {
"amount": 0.5,
"param0": 11,
"param1": 2,
"param2": 0,
"size": 4
},
"type": "remote",
"widgets": [
{
"label": "",
"linked_widgets": [
{
"node": "nm_postprocess",
"widget": "format"
}
],
"name": "param2",
"type": "linked_control"
},
{
"label": "",
"linked_widgets": [
{
"node": "buffer",
"widget": "size"
},
{
"node": "nm_convolution",
"widget": "size"
},
{
"node": "nm_postprocess",
"widget": "size"
}
],
"name": "param0",
"type": "linked_control"
},
{
"label": "",
"linked_widgets": [
{
"node": "nm_postprocess",
"widget": "amount"
}
],
"name": "param1",
"type": "linked_control"
}
]
},
{
"name": "gen_outputs",
"node_position": {
"x": -407.663818,
"y": 151.047363
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "rgba"
}
],
"type": "ios"
},
{
"name": "gen_inputs",
"node_position": {
"x": -870.910156,
"y": 157.047363
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "rgba"
}
],
"type": "ios"
}
],
"parameters": {
"amount": 0.5,
"param0": 11,
"param1": 2,
"param2": 0,
"size": 4
},
"type": "graph"
},
{
"name": "occlusion",
"node_position": {
"x": -81.811829,
"y": 56.5
},
"parameters": {
"param0": 8,
"param1": 50,
"param2": 5
},
"type": "occlusion"
},
{
"name": "colorize",
"node_position": {
"x": -58.5,
"y": 130
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0,
"r": 1
},
{
"a": 1,
"b": 0,
"g": 0,
"pos": 1,
"r": 0
}
],
"type": "Gradient"
}
},
"type": "colorize"
},
{
"name": "gen_inputs",
"node_position": {
"x": -381.811829,
"y": 49.5
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "rgba"
}
],
"type": "ios"
},
{
"name": "gen_outputs",
"node_position": {
"x": 244.5,
"y": 49.5
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "rgba"
},
{
"name": "port2",
"type": "rgba"
},
{
"name": "port1",
"type": "rgba"
}
],
"type": "ios"
},
{
"name": "gen_parameters",
"node_position": {
"x": -27.270599,
"y": -117
},
"parameters": {
},
"type": "remote",
"widgets": [
]
}
],
"parameters": {
},
"type": "graph"
},
{
"name": "colorize",
"node_position": {
"x": -486.598755,
"y": -27.262512
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0,
"r": 1
},
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0.027273,
"r": 0
}
],
"type": "Gradient"
}
},
"type": "colorize"
},
{
"name": "blend",
"node_position": {
"x": -718.608398,
"y": 67.325012
},
"parameters": {
"amount": 1,
"blend_type": 9
},
"type": "blend"
},
{
"name": "edge_detect_1",
"node_position": {
"x": -497.608398,
"y": -80.674988
},
"parameters": {
"size": 7
},
"type": "edge_detect_1"
},
{
"name": "box",
"node_position": {
"x": -988.422119,
"y": 68.460938
},
"parameters": {
"cx": 0.5,
"cy": 0.5,
"cz": 0.5,
"r": 0.5,
"rx": 40,
"ry": 40,
"rz": 90,
"sx": 0.25,
"sy": 0.25,
"sz": 0.25
},
"type": "box"
},
{
"name": "sphere",
"node_position": {
"x": -989.422119,
"y": -246.039063
},
"parameters": {
"cx": 0.5,
"cy": 0.5,
"r": 0.5
},
"type": "sphere"
}
],
"parameters": {
},
"type": "graph"
}

View File

@ -0,0 +1,118 @@
{
"name": "box",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"cx": 0.5,
"cy": 0.5,
"cz": 0.5,
"r": 0.5,
"rx": 0,
"ry": 0,
"rz": 0,
"sx": 0.25,
"sy": 0.25,
"sz": 0.25
},
"shader_model": {
"code": "",
"global": "float box(vec2 uv, vec3 center, vec3 rad, vec3 rot) {\n\tvec3 ro = vec3(uv, 1.0)-center;\n\tvec3 rd = vec3(0.0000001, 0.0000001, -1.0);\n\tmat3 r = mat3(vec3(1, 0, 0), vec3(0, cos(rot.x), -sin(rot.x)), vec3(0, sin(rot.x), cos(rot.x)));\n\tr *= mat3(vec3(cos(rot.y), 0, -sin(rot.y)), vec3(0, 1, 0), vec3(sin(rot.y), 0, cos(rot.y)));\n\tr *= mat3(vec3(cos(rot.z), -sin(rot.z), 0), vec3(sin(rot.z), cos(rot.z), 0), vec3(0, 0, 1));\n\tro = r * ro;\n\trd = r * rd;\n vec3 m = 1.0/rd;\n vec3 n = m*ro;\n vec3 k = abs(m)*rad;\n vec3 t1 = -n - k;\n vec3 t2 = -n + k;\n\n float tN = max(max(t1.x, t1.y), t1.z);\n float tF = min(min(t2.x, t2.y), t2.z);\n if(tN>tF || tF<0.0) return 1.0;\n return tN;\n}",
"inputs": [
],
"instance": "",
"name": "Box",
"outputs": [
{
"f": "1.0-box($uv, vec3($cx, $cy, $cz), vec3($sx, $sy, $sz), 0.01745329251*vec3($rx, $ry, $rz))",
"type": "f"
}
],
"parameters": [
{
"default": 0.5,
"label": "Center X",
"max": 1,
"min": 0,
"name": "cx",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Center Y",
"max": 1,
"min": 0,
"name": "cy",
"step": 0.01,
"type": "float"
},
{
"default": 0,
"label": "Center Z",
"max": 0.5,
"min": -0.5,
"name": "cz",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Size X",
"max": 1,
"min": 0,
"name": "sx",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Size Y",
"max": 1,
"min": 0,
"name": "sy",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Size Z",
"max": 1,
"min": 0,
"name": "sz",
"step": 0.01,
"type": "float"
},
{
"default": 0,
"label": "Rot X",
"max": 180,
"min": -180,
"name": "rx",
"step": 0.1,
"type": "float"
},
{
"default": 0,
"label": "Rot Y",
"max": 180,
"min": -180,
"name": "ry",
"step": 0.1,
"type": "float"
},
{
"default": 0,
"label": "Rot Z",
"max": 180,
"min": -180,
"name": "rz",
"step": 0.1,
"type": "float"
}
]
},
"type": "shader"
}

View File

@ -0,0 +1,57 @@
{
"name": "sphere",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"cx": 0.5,
"cy": 0.5,
"r": 0.5
},
"shader_model": {
"code": "",
"global": "float sphere(vec2 uv, vec2 c, float r) {\n\tuv -= c;\n\tuv /= r;\n\treturn 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv)));\n}\n",
"inputs": [
],
"instance": "",
"name": "Sphere",
"outputs": [
{
"f": "sphere($uv, vec2($cx, $cy), $r)",
"type": "f"
}
],
"parameters": [
{
"default": 0.5,
"label": "Center X",
"max": 1,
"min": 0,
"name": "cx",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Center Y",
"max": 1,
"min": 0,
"name": "cy",
"step": 0.01,
"type": "float"
},
{
"default": 0.5,
"label": "Radius",
"max": 1,
"min": 0,
"name": "r",
"step": 0.01,
"type": "float"
}
]
},
"type": "shader"
}