summaryrefslogtreecommitdiff
path: root/editor/plugins/texture_layered_editor_plugin.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-07-20 10:05:13 +0200
committerGitHub <noreply@github.com>2021-07-20 10:05:13 +0200
commit394191c02fedb0b3ff19ecf7410a85fe3f5cc691 (patch)
tree257ad8a4ad03ccba9f53dc713d69044c445830d5 /editor/plugins/texture_layered_editor_plugin.cpp
parentb4baec08cf4e623fe3caa03130fda8d366538c9e (diff)
parentabc38b8d66360060296d792a8cf65c33c6010e8a (diff)
Merge pull request #50605 from Calinou/tweak-shader-code-style
Use C++11 raw literals for shader code to improve readability
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 fb50e1c4a6..80359452ac 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();