1
0
Fork 0

Bugfix and noise seed option for ALS thrust flame shader

This commit is contained in:
Thorsten Renk 2017-04-17 10:30:49 +03:00
parent 99b893316d
commit b50af8ff47
2 changed files with 10 additions and 3 deletions

View file

@ -24,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>
<random_seed type="float">0.0</random_seed>
<deflection_coeff type="float">0.0</deflection_coeff>
<use_shocks type="int">1</use_shocks>
<use_noise type="int">1</use_noise>
@ -132,6 +133,11 @@
<type>float</type>
<value><use>noise_scale</use></value>
</uniform>
<uniform>
<name>random_seed</name>
<type>float</type>
<value><use>random_seed</use></value>
</uniform>
<uniform>
<name>flame_color_low_r</name>
<type>float</type>

View file

@ -14,6 +14,7 @@ uniform float shock_frequency;
uniform float noise_strength;
uniform float noise_scale;
uniform float deflection_coeff;
uniform float random_seed;
uniform float flame_color_low_r;
uniform float flame_color_low_g;
@ -65,7 +66,7 @@ if (d_rad > radius) {return 0.0;}
if (use_noise ==1)
{
noise = Noise2D(vec2(pos.x - osg_SimulationTime * 30.0 , d_rad), noise_scale);
noise = Noise2D(vec2(pos.x - osg_SimulationTime * 30.0 + random_seed , d_rad), noise_scale);
}
density *= (1.0 - smoothstep(0.125, radius, d_rad)) * (1.0 - noise_strength + noise_strength* noise);
@ -73,7 +74,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.25*flame_radius_fraction, 0.5*flame_radius_fraction, 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)) * (1.0 + 0.5 * base_flame_density);
}
@ -133,7 +134,7 @@ vec3 flame_color_low = vec3 (flame_color_low_r, flame_color_low_g, flame_color_l
vec3 flame_color_high = vec3 (flame_color_high_r, flame_color_high_g, flame_color_high_b);
vec3 color = mix(flame_color_low, flame_color_high, density2);
color = mix(color, vec3(0.8, 1.0, 1.0), density1);
color = mix(color, vec3(base_flame_r, base_flame_g, base_flame_b), density1);
vec4 finalColor = vec4 (color.rgb, density);