mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
1 line
1.8 KiB
Plaintext
1 line
1.8 KiB
Plaintext
|
{"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"}
|