summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2021-07-19 08:06:51 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2021-07-19 08:19:50 +0200
commitabc38b8d66360060296d792a8cf65c33c6010e8a (patch)
treebf453034e7d5f42393e24e1b9c66a7a991eb7346 /scene/gui
parentb76dfde329592ecfd6f6b952082ae21859039e67 (diff)
Use C++11 raw literals for shader code to improve readability
In files that have lots of branching, `\t` was replaced with a tab character instead.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp76
1 files changed, 41 insertions, 35 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 842cef3b83..eed6bcdbd2 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -97,43 +97,49 @@ Ref<Shader> ColorPicker::circle_shader;
void ColorPicker::init_shaders() {
wheel_shader.instantiate();
- wheel_shader->set_code(
- "shader_type canvas_item;"
- "void fragment() {"
- " float x = UV.x - 0.5;"
- " float y = UV.y - 0.5;"
- " float a = atan(y, x);"
- " x += 0.001;"
- " y += 0.001;"
- " float b = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);"
- " x -= 0.002;"
- " float b2 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);"
- " y -= 0.002;"
- " float b3 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);"
- " x += 0.002;"
- " float b4 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);"
- " COLOR = vec4(clamp((abs(fract(((a - TAU) / TAU) + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), (b + b2 + b3 + b4) / 4.00);"
- "}");
+ wheel_shader->set_code(R"(
+shader_type canvas_item;
+
+void fragment() {
+ float x = UV.x - 0.5;
+ float y = UV.y - 0.5;
+ float a = atan(y, x);
+ x += 0.001;
+ y += 0.001;
+ float b = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);
+ x -= 0.002;
+ float b2 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);
+ y -= 0.002;
+ float b3 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);
+ x += 0.002;
+ float b4 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);
+
+ COLOR = vec4(clamp((abs(fract(((a - TAU) / TAU) + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), (b + b2 + b3 + b4) / 4.00);
+}
+)");
circle_shader.instantiate();
- circle_shader->set_code(
- "shader_type canvas_item;"
- "uniform float v = 1.0;"
- "void fragment() {"
- " float x = UV.x - 0.5;"
- " float y = UV.y - 0.5;"
- " float a = atan(y, x);"
- " x += 0.001;"
- " y += 0.001;"
- " float b = float(sqrt(x * x + y * y) < 0.5);"
- " x -= 0.002;"
- " float b2 = float(sqrt(x * x + y * y) < 0.5);"
- " y -= 0.002;"
- " float b3 = float(sqrt(x * x + y * y) < 0.5);"
- " x += 0.002;"
- " float b4 = float(sqrt(x * x + y * y) < 0.5);"
- " COLOR = vec4(mix(vec3(1.0), clamp(abs(fract(vec3((a - TAU) / TAU) + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - vec3(3.0)) - vec3(1.0), 0.0, 1.0), ((float(sqrt(x * x + y * y)) * 2.0)) / 1.0) * vec3(v), (b + b2 + b3 + b4) / 4.00);"
- "}");
+ circle_shader->set_code(R"(
+shader_type canvas_item;
+
+uniform float v = 1.0;
+
+void fragment() {
+ float x = UV.x - 0.5;
+ float y = UV.y - 0.5;
+ float a = atan(y, x);
+ x += 0.001;
+ y += 0.001;
+ float b = float(sqrt(x * x + y * y) < 0.5);
+ x -= 0.002;
+ float b2 = float(sqrt(x * x + y * y) < 0.5);
+ y -= 0.002;
+ float b3 = float(sqrt(x * x + y * y) < 0.5);
+ x += 0.002;
+ float b4 = float(sqrt(x * x + y * y) < 0.5);
+
+ COLOR = vec4(mix(vec3(1.0), clamp(abs(fract(vec3((a - TAU) / TAU) + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - vec3(3.0)) - vec3(1.0), 0.0, 1.0), ((float(sqrt(x * x + y * y)) * 2.0)) / 1.0) * vec3(v), (b + b2 + b3 + b4) / 4.00);
+})");
}
void ColorPicker::finish_shaders() {