From aec9efe2e4b817f8ce9438deff2c44160e7b3879 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Sat, 23 May 2015 11:48:14 +0300 Subject: [PATCH] User-controlled bounding box utilization for thruster flame --- Effects/thrust-flame.eff | 13 ++++++++++++- Shaders/thrustflame-ALS.frag | 12 ++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Effects/thrust-flame.eff b/Effects/thrust-flame.eff index 67fe892cd..be854b8f3 100644 --- a/Effects/thrust-flame.eff +++ b/Effects/thrust-flame.eff @@ -8,6 +8,7 @@ white + 0.2 0.1 0.5 1.0 @@ -23,6 +24,7 @@ 1.0 0.8 0.3 + 0.0 1 1 /environment/ground-visibility-m @@ -95,6 +97,11 @@ Shaders/noise.frag + + flame_radius_fraction + float + flame_radius_fraction + thrust_collimation float @@ -170,7 +177,11 @@ float base_flame_b - + + deflection_coeff + float + deflection_coeff + use_shocks diff --git a/Shaders/thrustflame-ALS.frag b/Shaders/thrustflame-ALS.frag index 22de204ad..163333072 100644 --- a/Shaders/thrustflame-ALS.frag +++ b/Shaders/thrustflame-ALS.frag @@ -7,11 +7,13 @@ varying vec3 viewDir; uniform float osg_SimulationTime; uniform float thrust_collimation; +uniform float flame_radius_fraction; uniform float thrust_density; uniform float base_flame_density; uniform float shock_frequency; uniform float noise_strength; uniform float noise_scale; +uniform float deflection_coeff; uniform float flame_color_low_r; uniform float flame_color_low_g; @@ -38,7 +40,7 @@ float spherical_smoothstep (in vec3 pos) float l = length(vec3 (pos.x/2.0, pos.y,pos.z) ); -return 10.0 * thrust_density * base_flame_density * (1.0 - smoothstep(0.1, 0.2, l)); +return 10.0 * thrust_density * base_flame_density * (1.0 - smoothstep(0.5* flame_radius_fraction, flame_radius_fraction, l)); } @@ -51,12 +53,14 @@ float thrust_flame (in vec3 pos) //float noise = Noise3D(vec3(pos.x - osg_SimulationTime * 20.0 , pos.y, pos.z), 0.3); float noise = 0.0; -float d_rad = length(pos.yz); +pos.z +=8.0 * deflection_coeff; + +float d_rad = length(pos.yz - vec2 (0.0, deflection_coeff * pos.x * pos.x)); //float longFade = smoothstep(0.0, 5.0, pos.x) ; float longFade = pos.x/5.0; float density = 1.0 - longFade; -float radius = 0.2 + thrust_collimation * 1.2 * pow((pos.x+0.1),0.5); +float radius = flame_radius_fraction + thrust_collimation * 1.0 * pow((pos.x+0.1),0.5); if (d_rad > radius) {return 0.0;} @@ -71,7 +75,7 @@ density *= (1.0 - smoothstep(0.125, radius, d_rad)) * (1.0 - noise_strength + no if (use_shocks == 1) { float shock = sin(pos.x * 10.0 * shock_frequency); - density += shock * shock * shock * shock * (1.0 - longFade) * (1.0 - smoothstep(0.05, 0.1, d_rad)) * (1.0 - smoothstep(0.0, 1.0, thrust_collimation)); + density += shock * shock * shock * shock * (1.0 - longFade) * (1.0 - smoothstep(0.25*flame_radius_fraction, 0.5*flame_radius_fraction, d_rad)) * (1.0 - smoothstep(0.0, 1.0, thrust_collimation)); }