summaryrefslogtreecommitdiff
path: root/editor/plugins/animation_player_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/animation_player_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/animation_player_editor_plugin.cpp')
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index acfa873f62..cbce5bb3f5 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -1733,27 +1733,27 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial));
onion.capture.shader = Ref<Shader>(memnew(Shader));
- onion.capture.shader->set_code(" \
- shader_type canvas_item; \
- \
- uniform vec4 bkg_color; \
- uniform vec4 dir_color; \
- uniform bool differences_only; \
- uniform sampler2D present; \
- \
- float zero_if_equal(vec4 a, vec4 b) { \
- return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); \
- } \
- \
- void fragment() { \
- vec4 capture_samp = texture(TEXTURE, UV); \
- vec4 present_samp = texture(present, UV); \
- float bkg_mask = zero_if_equal(capture_samp, bkg_color); \
- float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); \
- diff_mask = min(1.0, diff_mask + float(!differences_only)); \
- COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \
- } \
- ");
+ onion.capture.shader->set_code(R"(
+shader_type canvas_item;
+
+uniform vec4 bkg_color;
+uniform vec4 dir_color;
+uniform bool differences_only;
+uniform sampler2D present;
+
+float zero_if_equal(vec4 a, vec4 b) {
+ return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0));
+}
+
+void fragment() {
+ vec4 capture_samp = texture(TEXTURE, UV);
+ vec4 present_samp = texture(present, UV);
+ float bkg_mask = zero_if_equal(capture_samp, bkg_color);
+ float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color);
+ diff_mask = min(1.0, diff_mask + float(!differences_only));
+ COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask);
+}
+)");
RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid());
}