From f17cf65f295f521692b1caa00d419523c2850784 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 26 Oct 2019 13:50:15 +0200 Subject: [PATCH] Added scratches generator --- addons/material_maker/nodes/scratches.mmg | 1 + 1 file changed, 1 insertion(+) create mode 100644 addons/material_maker/nodes/scratches.mmg diff --git a/addons/material_maker/nodes/scratches.mmg b/addons/material_maker/nodes/scratches.mmg new file mode 100644 index 0000000..a697534 --- /dev/null +++ b/addons/material_maker/nodes/scratches.mmg @@ -0,0 +1 @@ +{"name":"scratches","node_position":{"x":0,"y":0},"parameters":{"Randomness":0.5,"angle":-1,"layers":5,"length":0.25,"randomness":0.44,"waviness":0.51,"width":0.4},"shader_model":{"code":"","global":"float scratch(vec2 uv, vec2 size, float waviness, float angle, float randomness, vec2 seed) {\n\tfloat subdivide = floor(1.0/size.x);\n\tfloat cut = size.x*subdivide;\n\tuv *= subdivide;\n\tvec2 r1 = rand2(floor(uv)+seed);\n\tvec2 r2 = rand2(r1);\n\tuv = fract(uv);\n\tuv = 2.0*uv-vec2(1.0);\n\tfloat a = 6.28*(angle+(r1.x-0.5)*randomness);\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\tuv = vec2(c*uv.x+s*uv.y, s*uv.x-c*uv.y);\n\tuv.y += 2.0*r1.y-1.0;\n\tuv.y += 0.5*waviness*cos(2.0*uv.x+6.28*r2.y);\n\tuv.x /= cut;\n\tuv.y /= subdivide*size.y;\n\treturn (1.0-uv.x*uv.x)*max(0.0, 1.0-1000.0*uv.y*uv.y);\n}\n\nfloat scratches(vec2 uv, int layers, vec2 size, float waviness, float angle, float randomness, vec2 seed) {\n\tfloat v = 0.0;\n\tfor (int i = 0; i < layers; ++i) {\n\t\tv = max(v, scratch(fract(uv+seed), size, waviness, angle/360.0, randomness, seed));\n\t\tseed = rand2(seed);\n\t}\n\treturn v;\n}\n","inputs":[],"instance":"","name":"Scratches","outputs":[{"f":"scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2($seed, 0.0))","type":"f"}],"parameters":[{"default":0.25,"label":"Length","max":1,"min":0.1,"name":"length","step":0.01,"type":"float"},{"default":0.5,"label":"Width","max":1,"min":0.1,"name":"width","step":0.01,"type":"float"},{"default":4,"label":"Layers","max":10,"min":1,"name":"layers","step":1,"type":"float"},{"default":0.5,"label":"Waviness","max":1,"min":0,"name":"waviness","step":0.01,"type":"float"},{"default":0,"label":"Angle","max":180,"min":-180,"name":"angle","step":1,"type":"float"},{"default":0.5,"label":"Randomness","max":1,"min":0,"name":"randomness","step":0.01,"type":"float"}]},"type":"shader"} \ No newline at end of file