summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-11-20 10:59:34 +0100
committerGitHub <noreply@github.com>2017-11-20 10:59:34 +0100
commit341bf71dc17f8c4a84291b89a78ecc2936d85378 (patch)
tree5f5dbe8ee7c92b5c5049e6e2ddb2d1bdea3aeabe
parenta0f49396d6393219fed338f9a7f1e2df879b8ad7 (diff)
parent93be4982d012a25f034210623d50e519cdeddabf (diff)
Merge pull request #13023 from tom95/particles-align-y-12865
Make particles with DISABLE_Z active respect ALIGN_Y. Fixes #12865
-rw-r--r--scene/3d/particles.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 915a10328b..2a032f5d96 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -836,9 +836,15 @@ void ParticlesMaterial::_update_shader() {
if (flags[FLAG_DISABLE_Z]) {
- code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
+ code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(TRANSFORM[1].xyz,TRANSFORM[2].xyz));\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ } else {
+ code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ }
} else {
//orient particle Y towards velocity