material-maker/material_maker/examples/mandelbrot.ptex

173 lines
3.3 KiB
Plaintext

{
"connections": [
{
"from": "custom_0",
"from_port": 0,
"to": "colorize_0",
"to_port": 0
},
{
"from": "colorize_0",
"from_port": 0,
"to": "Material",
"to_port": 3
}
],
"label": "Graph",
"name": "362",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"name": "Material",
"node_position": {
"x": 200,
"y": 0
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 0,
"g": 0,
"r": 0,
"type": "Color"
},
"ao_light_affect": 1,
"depth_scale": 1,
"emission_energy": 1,
"metallic": 1,
"normal_scale": 1,
"resolution": 1,
"roughness": 1,
"size": 11
},
"type": "material"
},
{
"name": "custom_0",
"node_position": {
"x": -211,
"y": 208
},
"parameters": {
"contrast": 10,
"scale": 1,
"x": 0,
"y": 0
},
"shader_model": {
"global": "float mandelbrot(vec2 uv) {\n float di = 1.0;\n vec2 z = vec2(0.0);\n float m2 = 0.0;\n vec2 dz = vec2(0.0);\n for( int i=0; i<200; i++ )\n {\n if (m2>1024.0 ) {\n\t\t\tdi=0.0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Z' -> 2·Z·Z' + 1\n dz = 2.0*vec2(z.x*dz.x-z.y*dz.y, z.x*dz.y + z.y*dz.x) + vec2(1.0,0.0);\n\t\t\t\n // Z -> Z² + c\t\t\t\n z = vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ) + uv;\n\t\t\t\n m2 = dot(z,z);\n }\n\n // distance\t\n\t// d(c) = |Z|·log|Z|/|Z'|\n\tfloat d = 0.5*sqrt(dot(z,z)/dot(dz,dz))*log(dot(z,z));\n if( di>0.5 ) d=0.0;\n\treturn d;\n}",
"instance": "float $(name)_xyz(vec2 uv) {\n\treturn mandelbrot(uv);\n}",
"name": "Mandelbrot",
"outputs": [
{
"f": "clamp($(name)_xyz(vec2($(x), $(y))+$(scale)*(2.0*$(uv)-1.0))*$(contrast), 0.0, 1.0)",
"type": "f"
}
],
"parameters": [
{
"label": "Scale",
"max": 3,
"min": 0,
"name": "scale",
"step": 0.0001,
"type": "float",
"widget": "spinbox"
},
{
"label": "X",
"max": 2,
"min": -2,
"name": "x",
"step": 0.0001,
"type": "float",
"widget": "spinbox"
},
{
"label": "Y",
"max": 2,
"min": -2,
"name": "y",
"step": 0.0001,
"type": "float",
"widget": "spinbox"
},
{
"label": "Contrast",
"max": 10000,
"min": 1,
"name": "contrast",
"step": 0.0001,
"type": "float",
"widget": "spinbox"
}
]
},
"type": "shader"
},
{
"name": "colorize_0",
"node_position": {
"x": -99.75,
"y": -7.25
},
"parameters": {
"gradient": {
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0,
"r": 1
},
{
"a": 1,
"b": 0,
"g": 0.96875,
"pos": 0.2,
"r": 1
},
{
"a": 1,
"b": 0.0625,
"g": 1,
"pos": 0.4,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.618182,
"r": 0
},
{
"a": 1,
"b": 0.965909,
"g": 0,
"pos": 0.818182,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 0,
"pos": 1,
"r": 0.9375
}
],
"type": "Gradient"
}
},
"type": "colorize"
}
],
"parameters": {
},
"type": "graph"
}