material-maker/addons/material_maker/nodes/normal_map.mmg

279 lines
5.5 KiB
Plaintext

{
"connections": [
{
"from": "gen_inputs",
"from_port": 0,
"to": "buffer",
"to_port": 0
},
{
"from": "buffer",
"from_port": 0,
"to": "switch",
"to_port": 1
},
{
"from": "gen_inputs",
"from_port": 0,
"to": "switch",
"to_port": 0
},
{
"from": "edge_detect_1",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
},
{
"from": "switch",
"from_port": 0,
"to": "edge_detect_1",
"to_port": 0
}
],
"label": "Normal Map",
"longdesc": "Generates a normal map from a height map",
"name": "normal_map",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"name": "buffer",
"node_position": {
"x": -695.663818,
"y": 34.60614
},
"parameters": {
"lod": 0,
"size": 10
},
"type": "buffer"
},
{
"name": "gen_parameters",
"node_position": {
"x": -731.910156,
"y": -131.916687
},
"parameters": {
"param0": 10,
"param1": 1,
"param2": 0,
"param4": 1
},
"type": "remote",
"widgets": [
{
"label": "",
"linked_widgets": [
{
"node": "edge_detect_1",
"widget": "format"
}
],
"longdesc": "The format of the generated normal map\nIn most cases this should be set to default",
"name": "param2",
"shortdesc": "Format",
"type": "linked_control"
},
{
"label": "",
"linked_widgets": [
{
"node": "buffer",
"widget": "size"
},
{
"node": "edge_detect_1",
"widget": "size"
}
],
"longdesc": "The resolution of the generated normal map",
"name": "param0",
"shortdesc": "Resolution",
"type": "linked_control"
},
{
"label": "",
"linked_widgets": [
{
"node": "edge_detect_1",
"widget": "amount"
}
],
"longdesc": "The strength of the normal map filter",
"name": "param1",
"shortdesc": "Strength",
"type": "linked_control"
},
{
"configurations": {
"False": [
{
"node": "switch",
"value": 0,
"widget": "source"
}
],
"True": [
{
"node": "switch",
"value": 1,
"widget": "source"
}
]
},
"label": "Buffer",
"linked_widgets": [
{
"node": "switch",
"widget": "source"
}
],
"longdesc": "When set, a buffer is used to sample the input before the normal map filter",
"name": "param4",
"shortdesc": "Buffer",
"type": "config_control"
}
]
},
{
"name": "gen_outputs",
"node_position": {
"x": -445.663818,
"y": 75.047363
},
"parameters": {
},
"ports": [
{
"group_size": 0,
"longdesc": "Shows the generated normal map",
"name": "Normal",
"shortdesc": "Output",
"type": "rgb"
}
],
"type": "ios"
},
{
"name": "gen_inputs",
"node_position": {
"x": -1094.910156,
"y": 74.047363
},
"parameters": {
},
"ports": [
{
"group_size": 0,
"longdesc": "The input height map",
"name": "Bump",
"shortdesc": "Input",
"type": "f"
}
],
"seed_value": 12483,
"type": "ios"
},
{
"name": "switch",
"node_position": {
"x": -673.5,
"y": 113.297363
},
"parameters": {
"choices": 2,
"outputs": 1,
"source": 1
},
"type": "switch"
},
{
"name": "edge_detect_1",
"node_position": {
"x": -676.092529,
"y": 193.868774
},
"parameters": {
"amount": 1,
"format": 0,
"size": 10
},
"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": "0.0",
"function": true,
"label": "",
"name": "in",
"type": "f"
}
],
"instance": "vec3 $(name)_fct(vec2 uv) {\n\tvec3 e = vec3(1.0/$size, -1.0/$size, 0);\n\tvec2 rv = vec2(1.0, -1.0)*$in(uv+e.xy);\n\trv += vec2(-1.0, 1.0)*$in(uv-e.xy);\n\trv += vec2(1.0, 1.0)*$in(uv+e.xx);\n\trv += vec2(-1.0, -1.0)*$in(uv-e.xx);\n\trv += vec2(2.0, 0.0)*$in(uv+e.xz);\n\trv += vec2(-2.0, 0.0)*$in(uv-e.xz);\n\trv += vec2(0.0, 2.0)*$in(uv+e.zx);\n\trv += vec2(0.0, -2.0)*$in(uv-e.zx);\n\treturn vec3(rv, 0.0);\n}",
"name": "Normal map",
"outputs": [
{
"rgb": "process_normal_$format($(name)_fct($uv), $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": 12,
"name": "size",
"type": "size"
},
{
"control": "None",
"default": 0.5,
"label": "",
"max": 2,
"min": 0,
"name": "amount",
"step": 0.01,
"type": "float"
}
]
},
"type": "shader"
}
],
"parameters": {
"param0": 10,
"param1": 1,
"param2": 0,
"param4": 1
},
"shortdesc": "Normal map",
"type": "graph"
}