Skip to content

Commit 3be9fa2

Browse files
authored
Fixed "Fill To Random Color" repeating colors on adjacent tiles (contributed by DevFika)
Fix "Fill To Random Color" repeating colors on adjacent tiles
2 parents 5292f3d + 1323ff0 commit 3be9fa2

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "fill_to_random_color3",
3+
"node_position": {
4+
"x": 0,
5+
"y": 0
6+
},
7+
"parameters": {
8+
"edgecolor": {
9+
"a": 1,
10+
"b": 1,
11+
"g": 1,
12+
"r": 1,
13+
"type": "Color"
14+
}
15+
},
16+
"seed_int": 0,
17+
"shader_model": {
18+
"code": "vec4 $(name_uv)_bb = $in($uv);",
19+
"global": "",
20+
"inputs": [
21+
{
22+
"default": "vec4(0.0)",
23+
"label": "",
24+
"longdesc": "The input fill data, to be connected to the output of a Fill node",
25+
"name": "in",
26+
"shortdesc": "Input",
27+
"type": "fill"
28+
}
29+
],
30+
"instance": "",
31+
"longdesc": "A fill companion node that fills each area with a random color",
32+
"name": "Fill to Random Color ",
33+
"outputs": [
34+
{
35+
"longdesc": "The generated output image",
36+
"rgb": "mix($edgecolor.rgb, rand3_4d(vec4($(name_uv)_bb.xy, $(name_uv)_bb.z + float($seed), $(name_uv)_bb.w)), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))",
37+
"shortdesc": "Output",
38+
"type": "rgb"
39+
}
40+
],
41+
"parameters": [
42+
{
43+
"default": {
44+
"a": 1,
45+
"b": 1,
46+
"g": 1,
47+
"r": 1
48+
},
49+
"label": "Edge Color",
50+
"longdesc": "The color used for outlines",
51+
"name": "edgecolor",
52+
"shortdesc": "Outline color",
53+
"type": "color"
54+
}
55+
],
56+
"shortdesc": "Fill to random color"
57+
},
58+
"type": "shader"
59+
}

addons/material_maker/shader_functions.tres

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_resource type="Resource" script_class="TextResource" load_steps=2 format=3 uid="uid://by8m5knpg5yqf"]
22

3-
[ext_resource type="Script" path="res://addons/material_maker/engine/text_resource.gd" id="1_o2e2t"]
3+
[ext_resource type="Script" uid="uid://bc3eljtuurjsd" path="res://addons/material_maker/engine/text_resource.gd" id="1_o2e2t"]
44

55
[resource]
66
script = ExtResource("1_o2e2t")
@@ -22,6 +22,15 @@ vec3 rand3(vec2 x) {
2222
dot(x, vec2(3.4562, 17.398)),
2323
dot(x, vec2(13.254, 5.867))), vec3(3.14, 3.14, 3.14))) * 43758.5);
2424
}
25+
26+
vec3 rand3_4d(vec4 x) {
27+
return fract(cos(mod(vec3(
28+
dot(x, vec4(13.9898, 8.141, 3.4562, 17.398)),
29+
dot(x + 0.1234, vec4(3.4562, 17.398, 13.254, 5.867)),
30+
dot(x + 0.5678, vec4(11.1357, 23.234, 95.346, 9.123))
31+
), vec3(3.14))) * 43758.5);
32+
}
33+
2534
vec3 rgb2hsv(vec3 c) {
2635
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
2736
vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);

material_maker/library/base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@
30883088
}
30893089
},
30903090
"tree_item": "Filter/Fill/To Random Color",
3091-
"type": "fill_to_random_color2"
3091+
"type": "fill_to_random_color3"
30923092
},
30933093
{
30943094
"display_name": "To UV",

0 commit comments

Comments
 (0)