Updated Normal Map node (no format option anymore) and added a Normal map convert node

This commit is contained in:
Rodz Labs 2021-10-05 06:51:24 +02:00
parent 89d45a24ff
commit 24683a19a3
4 changed files with 376 additions and 5 deletions

View File

@ -399,7 +399,7 @@
"type": "rgb"
},
{
"rgb": "$normal_tex($uv)*vec3(-1.0, 1.0, 1.0)+vec3(1.0, 0.0, 0.0)",
"rgb": "$normal_tex($uv)*vec3(-1.0, 1.0, -1.0)+vec3(1.0, 0.0, 1.0)",
"type": "rgb"
},
{

View File

@ -0,0 +1,296 @@
{
"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_map2",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"name": "buffer",
"node_position": {
"x": -695.663818,
"y": 34.60614
},
"parameters": {
"lod": 0,
"size": 10
},
"seed": -32011,
"seed_locked": false,
"type": "buffer"
},
{
"name": "gen_parameters",
"node_position": {
"x": -809.910156,
"y": -136.916687
},
"parameters": {
"buffer": 1,
"param2": 0,
"size": 10,
"strength": 1
},
"seed": 56582,
"seed_locked": false,
"type": "remote",
"widgets": [
{
"label": "",
"linked_widgets": [
{
"node": "edge_detect_1",
"widget": "algo"
}
],
"longdesc": "The algorithm used to generate the normal map",
"name": "param2",
"shortdesc": "Algorithm",
"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": "size",
"shortdesc": "Resolution",
"type": "linked_control"
},
{
"label": "",
"linked_widgets": [
{
"node": "edge_detect_1",
"widget": "amount"
}
],
"longdesc": "The strength of the normal map filter",
"name": "strength",
"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": "buffer",
"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"
}
],
"seed": -6314,
"seed_locked": false,
"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": 12483,
"seed_locked": true,
"type": "ios"
},
{
"name": "switch",
"node_position": {
"x": -675.5,
"y": 110.297363
},
"parameters": {
"choices": 2,
"outputs": 1,
"source": 1
},
"seed": -53264,
"seed_locked": false,
"type": "switch"
},
{
"name": "edge_detect_1",
"node_position": {
"x": -678.092529,
"y": 187.868774
},
"parameters": {
"algo": 0,
"amount": 1,
"size": 10
},
"seed": -11547,
"seed_locked": false,
"shader_model": {
"code": "",
"global": "",
"inputs": [
{
"default": "0.0",
"function": true,
"label": "",
"name": "in",
"type": "f"
}
],
"instance": "vec3 nm_$name(vec2 uv, float amount, float size) {\n\tvec3 e = vec3(1.0/size, -1.0/size, 0);\n\tvec2 rv;\n\tif ($algo == 0) {\n\t\trv = vec2(1.0, -1.0)*$in(uv+e.xy);\n\t\trv += vec2(-1.0, 1.0)*$in(uv-e.xy);\n\t\trv += vec2(1.0, 1.0)*$in(uv+e.xx);\n\t\trv += vec2(-1.0, -1.0)*$in(uv-e.xx);\n\t\trv += vec2(2.0, 0.0)*$in(uv+e.xz);\n\t\trv += vec2(-2.0, 0.0)*$in(uv-e.xz);\n\t\trv += vec2(0.0, 2.0)*$in(uv+e.zx);\n\t\trv += vec2(0.0, -2.0)*$in(uv-e.zx);\n\t\trv *= size*amount/128.0;\n\t} else if ($algo == 1) {\n\t\trv = vec2(3.0, -3.0)*$in(uv+e.xy);\n\t\trv += vec2(-3.0, 3.0)*$in(uv-e.xy);\n\t\trv += vec2(3.0, 3.0)*$in(uv+e.xx);\n\t\trv += vec2(-3.0, -3.0)*$in(uv-e.xx);\n\t\trv += vec2(10.0, 0.0)*$in(uv+e.xz);\n\t\trv += vec2(-10.0, 0.0)*$in(uv-e.xz);\n\t\trv += vec2(0.0, 10.0)*$in(uv+e.zx);\n\t\trv += vec2(0.0, -10.0)*$in(uv-e.zx);\n\t\trv *= size*amount/512.0;\n\t} else if ($algo == 2) {\n\t\trv += vec2(2.0, 0.0)*$in(uv+e.xz);\n\t\trv += vec2(-2.0, 0.0)*$in(uv-e.xz);\n\t\trv += vec2(0.0, 2.0)*$in(uv+e.zx);\n\t\trv += vec2(0.0, -2.0)*$in(uv-e.zx);\n\t\trv *= size*amount/64.0;\n\t} else {\n\t\trv += vec2(1.0, 0.0)*$in(uv+e.xz);\n\t\trv += vec2(0.0, 1.0)*$in(uv+e.zx);\n\t\trv += vec2(-1.0, -1.0)*$in(uv);\n\t\trv *= size*amount/20.0;\n\t}\n\treturn vec3(0.5)+0.5*normalize(vec3(rv, -1.0));\n}\n",
"name": "Normal map",
"outputs": [
{
"rgb": "nm_$name($uv, $amount, $size)",
"type": "rgb"
}
],
"parameters": [
{
"default": 3,
"label": "",
"name": "algo",
"type": "enum",
"values": [
{
"name": "Sobel",
"value": "0"
},
{
"name": "Scharr",
"value": "1"
},
{
"name": "Simple",
"value": "2"
},
{
"name": "Cheap",
"value": "3"
}
]
},
{
"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": {
"buffer": 1,
"param2": 0,
"size": 10,
"strength": 1
},
"seed": 0,
"seed_locked": false,
"shortdesc": "Normal map",
"type": "graph"
}

View File

@ -0,0 +1,59 @@
{
"name": "normal_map_convert",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"op": 0
},
"seed": 0,
"seed_locked": false,
"shader_model": {
"code": "",
"global": "",
"inputs": [
{
"default": "vec3(0.5, 0.5, 1.0)",
"label": "",
"longdesc": "The input image",
"name": "in",
"shortdesc": "Input",
"type": "rgb"
}
],
"instance": "",
"longdesc": "Convert a normal map between OpenGL (default) and DirectX formats",
"name": "Convert Normal Map",
"outputs": [
{
"longdesc": "Shows the image with adjusted Hue, Saturation and Value",
"rgb": "$in($(uv))$op",
"shortdesc": "Output",
"type": "rgb"
}
],
"parameters": [
{
"default": 1,
"label": "",
"longdesc": "The conversion that should be performed",
"name": "op",
"shortdesc": "Conversion",
"type": "enum",
"values": [
{
"name": "From/To OpenGL",
"value": "*vec3(-1.0, 1.0, -1.0)+vec3(1.0, 0.0, 1.0)"
},
{
"name": "From/To DirectX",
"value": "*vec3(-1.0, -1.0, -1.0)+vec3(1.0, 1.0, 1.0)"
}
]
}
],
"shortdesc": "Convert Normal Map"
},
"type": "shader"
}

File diff suppressed because one or more lines are too long