diff --git a/Aircraft/Generic/Effects/Thruster/thrust_flame.ac b/Aircraft/Generic/Effects/Thruster/thrust_flame.ac new file mode 100644 index 000000000..298a6e540 --- /dev/null +++ b/Aircraft/Generic/Effects/Thruster/thrust_flame.ac @@ -0,0 +1,61 @@ +AC3Db +MATERIAL "DefaultWhite" rgb 1.0000 1.0000 1.0000 amb 0.2000 0.2000 0.2000 emis 0.0000 0.0000 0.0000 spec 0.5000 0.5000 0.5000 shi 10 trans 0.5000 +MATERIAL "Material" rgb 0.8000 0.8000 0.8000 amb 1.0000 1.0000 1.0000 emis 0.0000 0.0000 0.0000 spec 0.5000 0.5000 0.5000 shi 50 trans 0.5000 +OBJECT world +name "Blender_export__cube.ac" +kids 1 +OBJECT poly +name "Bounding_box" +numvert 8 +5.0 -1.0 -1.0 +5.0 -1.0 1.0 +0.0 -1.0 1.0 +0.0 -1.0 -1.0 +5.0 1.0 -1.0 +5.0 1.0 1.0 +0.0 1.0 1.0 +0.0 1.0 -1.0 +numsurf 6 +SURF 0X20 +mat 1 +refs 4 +0 0 0 +1 0 0 +2 0 0 +3 0 0 +SURF 0X20 +mat 1 +refs 4 +4 0 0 +7 0 0 +6 0 0 +5 0 0 +SURF 0X20 +mat 1 +refs 4 +0 0 0 +4 0 0 +5 0 0 +1 0 0 +SURF 0X20 +mat 1 +refs 4 +1 0 0 +5 0 0 +6 0 0 +2 0 0 +SURF 0X20 +mat 1 +refs 4 +2 0 0 +6 0 0 +7 0 0 +3 0 0 +SURF 0X20 +mat 1 +refs 4 +4 0 0 +0 0 0 +3 0 0 +7 0 0 +kids 0 diff --git a/Effects/thrust-flame.eff b/Effects/thrust-flame.eff new file mode 100644 index 000000000..f6bc85473 --- /dev/null +++ b/Effects/thrust-flame.eff @@ -0,0 +1,171 @@ + + + + Effects/thrust-flame + + + + white + + 0.1 + 0.5 + 0.5 + 0.2 + 0.1 + 0.95 + 0.55 + 0.0 + 1.0 + 0.8 + 0.3 + 1 + 1 + + + + + + /sim/rendering/shaders/skydome + + + 2.0 + + + + GL_ARB_shader_objects + GL_ARB_shading_language_100 + GL_ARB_vertex_shader + GL_ARB_fragment_shader + + + + + + true + + material/active + material/ambient + material/diffuse + material/specular + material/emissive + material/shininess + material/color-mode + + + blend/active + blend/source + blend/destination + + shade-model + cull-face + rendering-hint + + 111 + DepthSortedBin + + + + 0 + texture[0]/active + texture[0]/type + texture[0]/image + texture[0]/filter + texture[0]/wrap-s + texture[0]/wrap-t + texture[0]/internal-format + + + false + + false + + Shaders/thrustflame-ALS.vert + Shaders/thrustflame-ALS.frag + Shaders/noise.frag + + + + thrust_collimation + float + thrust_collimation + + + thrust_density + float + thrust_density + + + shock_frequency + float + shock_frequency + + + noise_strength + float + noise_strength + + + noise_scale + float + noise_scale + + + flame_color_low_r + float + flame_color_low_r + + + flame_color_low_g + float + flame_color_low_g + + + flame_color_low_b + float + flame_color_low_b + + + flame_color_high_r + float + flame_color_high_r + + + flame_color_high_g + float + flame_color_high_g + + + flame_color_high_b + float + flame_color_high_b + + + + + use_shocks + int + use_shocks + + + use_noise + int + use_noise + + + + + + texture + sampler-2d + 0 + + + colorMode + int + material/color-mode-uniform + + + + + diff --git a/Shaders/thrustflame-ALS.frag b/Shaders/thrustflame-ALS.frag new file mode 100644 index 000000000..952003174 --- /dev/null +++ b/Shaders/thrustflame-ALS.frag @@ -0,0 +1,124 @@ +// -*-C++-*- + + +varying vec3 vertex; +varying vec3 viewDir; + +uniform float osg_SimulationTime; +uniform float thrust_collimation; +uniform float thrust_density; +uniform float shock_frequency; +uniform float noise_strength; +uniform float noise_scale; + +uniform float flame_color_low_r; +uniform float flame_color_low_g; +uniform float flame_color_low_b; + +uniform float flame_color_high_r; +uniform float flame_color_high_g; +uniform float flame_color_high_b; + +uniform int use_shocks; +uniform int use_noise; + +float Noise3D(in vec3 coord, in float wavelength); +float Noise2D(in vec2 coord, in float wavelength); + +const int n_steps = 100; + +float spherical_smoothstep (in vec3 pos) +{ + +float noise = Noise3D(vec3(pos.x - osg_SimulationTime * 5.0 , pos.y, pos.z), 0.3); + +pos *=4.0; + +pos.x *=0.5; +float d = length(pos); + + + +return 3.0 * (1.0 - smoothstep(0.3, 0.7, d)) /float(n_steps)* (0.5 + 0.5 * noise); +} + +float spherical_smoothstep1 (in vec3 pos) +{ +pos.x *=0.2; +float d = length(pos); + +return 1.0 * (1.0 - smoothstep(0.3, 0.7, d)) /float(n_steps); +} + +float thrust_flame (in vec3 pos) +{ + + +//float noise = Noise3D(vec3(pos.x - osg_SimulationTime * 20.0 , pos.y, pos.z), 0.3); +float noise = Noise2D(vec2(pos.x - osg_SimulationTime * 30.0 , length(pos.yz)), noise_scale); + +float d = 1.0 - pos.x/2.5 ; +float radius = 0.2 + thrust_collimation * 1.4 * pow((pos.x+0.1),0.5); + +d *= (1.0 - smoothstep(0.125, radius, length(pos.yz))) * (1.0 - noise_strength + noise_strength* noise); + +if (use_shocks == 1) + { + float shock = sin(pos.x * 20.0 * shock_frequency); + d += shock * shock * shock * shock * (1.0 - pos.x/2.5) * (1.0 - smoothstep(0.05, 0.1, length(pos.yz))) * (1.0 - smoothstep(0.0, 1.0, thrust_collimation)); + } + +return 10.0 * thrust_density * d / (radius/0.2); +} + + + +void main() +{ + +float t_x = 2.0 * abs(vertex.x) / max(viewDir.x, 0.0001); +float t_y = 2.0 * abs(vertex.y) / max(viewDir.y, 0.0001); +float t_z = 2.0 * abs(vertex.z) / max(viewDir.z, 0.0001); + +float t_min = min(t_x, t_y); +t_min = min(t_min, t_z); + +t_min = 5.0; + +float dt = t_min / float(n_steps); + +vec3 step = viewDir * dt; +vec3 pos = vertex; + +float density1 = 0.0; +float density2 = 0.0; + + + +for (int i = 0; i < n_steps; i++) + { + pos = pos + step; + if ((pos.x > 5.0) || (pos.x <0.0)) {break;} + if ((pos.y > 1.0) || (pos.y <-1.0)) {break;} + if ((pos.z > 1.0) || (pos.z <-1.0)) {break;} + //density1 += spherical_smoothstep(pos); + //density2 += spherical_smoothstep1(pos); + density2 += thrust_flame(pos) * dt; + } + + + + +float density = density1 + density2; +density = clamp(density,0.0,1.0); + + +vec3 flame_color_low = vec3 (flame_color_low_r, flame_color_low_g, flame_color_low_b); +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+density1); + +vec4 finalColor = vec4 (color.rgb, density); + +gl_FragColor = finalColor; +} diff --git a/Shaders/thrustflame-ALS.vert b/Shaders/thrustflame-ALS.vert new file mode 100644 index 000000000..c0668e3ca --- /dev/null +++ b/Shaders/thrustflame-ALS.vert @@ -0,0 +1,19 @@ +// -*-C++-*- + +varying vec3 vertex; +varying vec3 viewDir; + +void main() +{ + +vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0); + +vertex = gl_Vertex.xyz; +viewDir = normalize(vertex - ep.xyz); + +gl_Position = ftransform(); +gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + +gl_FrontColor = vec4 (1.0,1.0,1.0,1.0); +gl_BackColor = gl_FrontColor; +}