summaryrefslogtreecommitdiff
path: root/editor/plugins/texture_layered_editor_plugin.cpp
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 /editor/plugins/texture_layered_editor_plugin.cpp
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 'editor/plugins/texture_layered_editor_plugin.cpp')
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp67
1 files changed, 35 insertions, 32 deletions
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index 3f46cd64a2..97b45a4f28 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -104,43 +104,46 @@ void TextureLayeredEditor::_update_material() {
}
void TextureLayeredEditor::_make_shaders() {
- String shader_2d_array = ""
- "shader_type canvas_item;\n"
- "uniform sampler2DArray tex;\n"
- "uniform float layer;\n"
- "void fragment() {\n"
- " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n"
- "}";
-
shaders[0].instantiate();
- shaders[0]->set_code(shader_2d_array);
-
- String shader_cube = ""
- "shader_type canvas_item;\n"
- "uniform samplerCube tex;\n"
- "uniform vec3 normal;\n"
- "uniform mat3 rot;\n"
- "void fragment() {\n"
- " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n"
- " COLOR = textureLod(tex,n,0.0);\n"
- "}";
+ shaders[0]->set_code(R"(
+shader_type canvas_item;
+
+uniform sampler2DArray tex;
+uniform float layer;
+
+void fragment() {
+ COLOR = textureLod(tex, vec3(UV, layer), 0.0);
+}
+)");
shaders[1].instantiate();
- shaders[1]->set_code(shader_cube);
-
- String shader_cube_array = ""
- "shader_type canvas_item;\n"
- "uniform samplerCubeArray tex;\n"
- "uniform vec3 normal;\n"
- "uniform mat3 rot;\n"
- "uniform float layer;\n"
- "void fragment() {\n"
- " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n"
- " COLOR = textureLod(tex,vec4(n,layer),0.0);\n"
- "}";
+ shaders[1]->set_code(R"(
+shader_type canvas_item;
+
+uniform samplerCube tex;
+uniform vec3 normal;
+uniform mat3 rot;
+
+void fragment() {
+ vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
+ COLOR = textureLod(tex, n, 0.0);
+}
+)");
shaders[2].instantiate();
- shaders[2]->set_code(shader_cube_array);
+ shaders[2]->set_code(R"(
+shader_type canvas_item;
+
+uniform samplerCubeArray tex;
+uniform vec3 normal;
+uniform mat3 rot;
+uniform float layer;
+
+void fragment() {
+ vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z));
+ COLOR = textureLod(tex, vec4(n, layer), 0.0);
+}
+)");
for (int i = 0; i < 3; i++) {
materials[i].instantiate();