1
0
Fork 0

User-controlled bounding box utilization for thruster flame

This commit is contained in:
Thorsten Renk 2015-05-23 11:48:14 +03:00
parent 059789a4bd
commit aec9efe2e4
2 changed files with 20 additions and 5 deletions

View file

@ -8,6 +8,7 @@
<type>white</type>
</texture>
<flame_radius_fraction type="float">0.2</flame_radius_fraction>
<thrust_collimation type="float">0.1</thrust_collimation>
<thrust_density type="float">0.5</thrust_density>
<base_flame_density type="float">1.0</base_flame_density>
@ -23,6 +24,7 @@
<base_flame_r type="float">1.0</base_flame_r>
<base_flame_g type="float">0.8</base_flame_g>
<base_flame_b type="float">0.3</base_flame_b>
<deflection_coeff type="float">0.0</deflection_coeff>
<use_shocks type="int">1</use_shocks>
<use_noise type="int">1</use_noise>
<visibility><use>/environment/ground-visibility-m</use></visibility>
@ -95,6 +97,11 @@
<fragment-shader>Shaders/noise.frag</fragment-shader>
</program>
<uniform>
<name>flame_radius_fraction</name>
<type>float</type>
<value><use>flame_radius_fraction</use></value>
</uniform>
<uniform>
<name>thrust_collimation</name>
<type>float</type>
@ -170,7 +177,11 @@
<type>float</type>
<value><use>base_flame_b</use></value>
</uniform>
<uniform>
<name>deflection_coeff</name>
<type>float</type>
<value><use>deflection_coeff</use></value>
</uniform>
<uniform>
<name>use_shocks</name>

View file

@ -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));
}