From 4f51ab3bec927df853ef3fcd318b11fc30c75d2d Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Wed, 11 Nov 2015 11:34:41 +0200 Subject: [PATCH] Wing sweep animation for ALS wingflex shader --- Shaders/model-ALS-wingflex-organic.vert | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Shaders/model-ALS-wingflex-organic.vert b/Shaders/model-ALS-wingflex-organic.vert index 9a5c556ac..23eeeb3f4 100644 --- a/Shaders/model-ALS-wingflex-organic.vert +++ b/Shaders/model-ALS-wingflex-organic.vert @@ -24,6 +24,7 @@ uniform float roll; uniform float hdg; uniform float wingflex_alpha; uniform float wingflex_trailing_alpha; +uniform float wingsweep_factor; uniform int refl_dynamic; uniform int nmap_enabled; uniform int shader_qual; @@ -56,8 +57,8 @@ void main(void) float x_factor = max((abs(vertex.x) - 1.2),0); float y_factor = max(vertex.y,0.0); - float flex_factor1 = wingflex_alpha; - float flex_factor2 = wingflex_trailing_alpha; + float flex_factor1 = wingflex_alpha * wingsweep_factor; + float flex_factor2 = wingflex_trailing_alpha * wingsweep_factor; if (flex_factor1<0.0) {flex_factor1 *=0.7;} if (flex_factor2<0.0) {flex_factor1 *=0.7;} @@ -72,6 +73,14 @@ void main(void) vertex.z += 0.2 * y_factor * x_factor * flex_factor2; + // if the wings are folded, we sweep them back + vertex.y += 0.5 * x_factor * (1.0-wingsweep_factor); + float sweep_x = 0.5; + if (vertex.x > 0.0) {sweep_x = - 0.5;} + + vertex.x+= sweep_x * (1.0 + 0.5 *x_factor) * (1.0 - wingsweep_factor); + + rawpos = vertex.xyz; vec4 ecPosition = gl_ModelViewMatrix * vertex;