Flaming Wreckage! - Possible with scripting?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

User avatar
Captain Hesperus
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
Posts: 2312
Joined: Tue Sep 19, 2006 1:10 pm
Location: Anywhere I can sell Trumbles.....

Post by Captain Hesperus »

Commander McLane wrote:
Captain Hesperus wrote:
As the metal disintegrates, it'd lose a lot of heat rapidly into the stellar environment...
I would like to ask that as a question to the people who know more about physics than I do. Would it really? Lose a lot of heat rapidly into what exactly? How would heat dissipate in vacuum? Objects on earth cool because their heat dissipates into the surrounding medium, be it air, water, earth, whatever. But in a vacuum there is by definition no surrounding medium. So my gut tells me that a hot object would not lose a lot of heat rapidly, but stay hot for a long time. Or am I wrong here? :?:
The heat can be lost in several forms, in an atmosphere it is lost by convection, conduction and radiation. Convection is the heating of the air, causing hot air to rise and cool air to fall, creating convection 'cells'. Conduction is, of course, heat loss through contact with another, colder object, such as when you hold a glass of iced water, you feel the cold as your hand conducts heat through to the glass and water. Finally radiation is direct energy given off as infra-red radiation.
This radiation is usually the method of heat loss in space, several satellites use radiation to vent excess electricity from fixed solar panels to prevent overloading their onboard batteries by passing excess current through resistors, heating them and allowing them to radiate off the heat.
http://www.qrg.northwestern.edu/project ... space.html

Captain Hesperus
The truth, revealed!!
Image
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Captain Hesperus wrote:
The heat can be lost in several forms, in an atmosphere it is lost by convection, conduction and radiation. ......
You miss the most obvious object that dissipates heat by radiation: our sun and all other stars. The hotter, the higher the part of short wave radiation. At a few hundred degree C it is mainly emitting infrared and at a few thousand it is mainly emitting visible light and UV radiation.

During my study I even had to do some calculations on it. A sphere in space is heated up by a sun and dissipates heat by radiation. You can even calculate what the equilibrium temperature of the sphere will become after some time.
McLane wrote:
Objects on earth cool because their heat dissipates into the surrounding medium, be it air, water, earth, whatever.
At low temperatures that is the main reason for heat dissipation but already at the temperature of a light bulb, dissipation by electro magnetic radiation (IR and light) becomes the main source of heat dissipation.

Griff: great work. I now really need shaders.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Getting rid of heat is one of the biggest problems in real-world spaceship design. The reason the space shuttle always has its doors open in pictures is that if it flew with them shut too long, the astronauts would bake. The insides of the doors are covered with radiators.
Eric Walch wrote:
At low temperatures that is the main reason for heat dissipation but already at the temperature of a light bulb, dissipation by electro magnetic radiation (IR and light) becomes the main source of heat dissipation.
Is that the surface of the light bulb, or the several thousand degrees of the filament? ;-)
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

rendermonkey says Success!
Thanks for the code snippet Ahruman, I've added it in to the shader, the heat & flaking away effects now fade out properly and junk chunks should burn for varying lengths of time using the randomFloat shader uniform binding!

Code: Select all

// Uniforms from Oolite
   uniform sampler2D    uColorMap;
   uniform sampler2D    uNormalMap;
   uniform sampler2D    uEffectsMap;

   uniform float  uTime;
   uniform float  timeElapsedSinceSpawn;
   uniform float  FadeTime; // Random value supplied by Oolite using 'randomFloat' (in the range 0.0 - 1.0)

// Info from the vertex shader
   varying vec2         vTexCoord;
   varying vec3         vEyeVector;   // These are all in tangent space
   varying vec3         vLight0Vector;
   varying vec3         vLight1Vector;
 
// Constants
   float kInitialHeat = 5.0;
   const float KspecExponent = 5.0;
   const float kSpecular = 0.4;

// Set up the total burntime
   float FadeTime2 = FadeTime * 100.0; // Multiply FadeTime by 100 to lengthen the burn time
   float  FadeFactor = kInitialHeat / FadeTime2;

// Irregular flickering function used to flicker the heated metal
   #ifdef OO_REDUCED_COMPLEXITY 
   #define Pulse(v, ts) ((v) * 0.95) 
   #else

     float Pulse(float value, float timeScale)
     {
        float t = uTime * timeScale;   

        float s0 = t;
        s0 -= floor(s0);
        float sum = abs( s0 - 0.5);
   
        float s1 = t * 0.7 - 0.05;
        s1 -= floor(s1);
        sum += abs(s1 - 0.5) - 0.25;
   
        float s2 = t * 1.3 - 0.3;
        s2 -= floor(s2);
        sum += abs(s2 - 0.5) - 0.25;
   
        float s3 = t * 5.09 - 0.6;
        s3 -= floor(s3);
        sum += abs(s3 - 0.5) - 0.25;

        return (sum * 0.4 + 0.9) * value;
      }

// Hot Glowing Metal Function.
   vec4 MetalGlow(float level)
   {
   vec4 result;
   result.rgb = vec3(2.0, 0.5, 0.25) * level;
   result.a = 1.0;
   return result;
   }
   
#endif

void Light(in vec3 lightVector, in vec3 normal, in vec4 lightColor, in vec3 eyeVector, 
           in float KspecExponent, inout vec4 totalDiffuse, inout vec4 totalSpecular)
{
   lightVector = normalize(lightVector);
   vec3 reflection = normalize(-reflect(lightVector, normal));
   
   totalDiffuse += gl_FrontMaterial.diffuse * lightColor * max(dot(normal, lightVector), 0.0);
   totalSpecular += lightColor * pow(max(dot(reflection, eyeVector), 0.0), KspecExponent);
}


#define LIGHT(idx, vector) Light(vector, normal, gl_LightSource[idx].diffuse, eyeVector, KspecExponent, diffuse, specular)

void main()
{
   vec3 eyeVector = normalize(vEyeVector);
   vec2 texCoord = vTexCoord;
   
   vec3 normal = normalize( texture2D(uNormalMap, texCoord).xyz - 0.5);
   normal = normalize(normal);

   vec4 colorMap = texture2D(uColorMap, texCoord);
   vec4 clipMap = texture2D(uEffectsMap, texCoord);
   vec4 diffuse = vec4(0.0), specular = vec4(0);

   float specIntensity = colorMap.a;

#ifdef OO_LIGHT_0_FIX
   LIGHT(0, normalize(vLight0Vector));
#endif
   LIGHT(0, normalize(vLight1Vector)); // change the 0 to 1 when saving the shader for oolite
   diffuse += gl_FrontMaterial.ambient * gl_LightSource[0].ambient;

/* Make the crinkly edge, use the red channel from the effects texture as a clipmap, 
   ramp up the intensity to eat away the polygon over time but stop it at FadeTime2 
   (FadeTime2 is the random float 'FadeTime' supplied by Oolite multiplied by 100) 
   This allows each fragment to burn for a random length of time */
   float BurnAway = clipMap.r * min(timeElapsedSinceSpawn, FadeTime2);  
   if (BurnAway > 0.9)  discard; 

// Calculate the lighting 
   vec4 color = diffuse * colorMap;
   color += colorMap * specular * 6.0 * specIntensity;   

// Add the glowing metal effect
   float metalTemperature = max(0.0, kInitialHeat - FadeFactor * timeElapsedSinceSpawn);
   float Heat = max(metalTemperature - 0.5, 0.0);
   Heat = Pulse(metalTemperature, 0.5);
   float FinalTemperature = BurnAway * (Heat + metalTemperature); 
   color += MetalGlow(FinalTemperature) * colorMap;

   gl_FragColor = color;
}
Last edited by Griff on Sat Feb 07, 2009 4:10 pm, edited 1 time in total.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Just don't forget to change the "lifetime" set in the scripting for the larger bits, or else they'll blow up before they've done their graphical thang ;)
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Ahruman wrote:
Is that the surface of the light bulb, or the several thousand degrees of the filament? ;-)
That's the filament temperature I refer to. About 20 years ago I wrote a small article about the exact working of a halogen bulb. (both the chemical and physical phenomena). But it gets a bit blurry after so much time.
The first experimental bulbs started with filaments in vacuum to prevent heat conduction. But filament evaporation is to fast without counter pressure that the filament has a very short live time. One needs a non reactive gas for longer living of the filament. And the higher the density of the surrounding gas, the better the filament is isolated. Therefor a cheap bulb uses argon as filling but a more expensive bulb uses krypton or even xenon. A better isolation means that a higher percentage of the energy input is going out by radiation instead by confection.

But enough about bulbs. Back to the burning wreckage and an explanation of this phenomena. For burning you need two components and a chemical reaction between the two. On earth it would be metal and oxygen. This makes flaming wreckage in space less realistic, but..

The oxygen does not need to be present as gas. Space shuttle solid fuel rocket boosters use aluminium powder and an oxygen containing ammonium perchlorate. The oxygen than is transferred to the aluminium. This gives so much heat that all components leave as gas.
Or when you mix aluminium powder with iron oxide and heat it up, the oxygen will be transferred from the iron oxide to the aluminium once the temperature is high enough. By this it generates very much extra heat that you get a thermic lance.

So one could assume the plating of the ship are build of an alloy that is unstable at high temperatures and that is also extremely strong and stable enough at normal temperatures to be safely used. When heated up it will decompose itself. That would also explain why a simple laser shot not just burns a hole in the hull but always seems the disintegrate the whole ship. Once the chain reaction starts, the whole hull burns away. Only interior parts made of normal alloys survive. e.g. the fridge.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

The new shader version:
Image
I must point out that it's based almost entirely on Ahrumans 'normal mapped shader' & 'glowing alloy shader' examples, so all credit to the big A!
User avatar
Captain Hesperus
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
Posts: 2312
Joined: Tue Sep 19, 2006 1:10 pm
Location: Anywhere I can sell Trumbles.....

Post by Captain Hesperus »

Griff wrote:
The new shader version:
Image
I must point out that it's based almost entirely on Ahrumans 'normal mapped shader' & 'glowing alloy shader' examples, so all credit to the big A!
Sweet!!!!

Captain Hesperus
The truth, revealed!!
Image
User avatar
wackyman465
---- E L I T E ----
---- E L I T E ----
Posts: 831
Joined: Thu Nov 06, 2008 10:15 pm
Location: Currently hunting you down in an Imperial Courier

Post by wackyman465 »

Wow. Amazing. I want!
I shot him back first. That is to say, I read his mind and fired before he would have fired on me. No, sir, he wasn't a fugitive.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Your next task, should you choose to accept it, is to tweak the burniness map so you don’t end up with unattached bits. :-)
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Really, really nice Griff.

I like Eric's explanation of why the ships vaporise once fully compromised. Real physics meets observable oolite reality. nice.
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Pangloss
---- E L I T E ----
---- E L I T E ----
Posts: 303
Joined: Wed Dec 13, 2006 5:57 pm
Location: Scranton, PA (via Stevenage, Herts)

Post by Pangloss »

Eric Walch wrote:
Ahruman wrote:
Is that the surface of the light bulb, or the several thousand degrees of the filament? ;-)
That's the filament temperature I refer to. About 20 years ago I wrote a small article about the exact working of a halogen bulb. (both the chemical and physical phenomena). But it gets a bit blurry after so much time.
The first experimental bulbs started with filaments in vacuum to prevent heat conduction. But filament evaporation is to fast without counter pressure that the filament has a very short live time. One needs a non reactive gas for longer living of the filament. And the higher the density of the surrounding gas, the better the filament is isolated. Therefor a cheap bulb uses argon as filling but a more expensive bulb uses krypton or even xenon. A better isolation means that a higher percentage of the energy input is going out by radiation instead by confection.

But enough about bulbs. Back to the burning wreckage and an explanation of this phenomena. For burning you need two components and a chemical reaction between the two. On earth it would be metal and oxygen. This makes flaming wreckage in space less realistic, but..

The oxygen does not need to be present as gas. Space shuttle solid fuel rocket boosters use aluminium powder and an oxygen containing ammonium perchlorate. The oxygen than is transferred to the aluminium. This gives so much heat that all components leave as gas.
Or when you mix aluminium powder with iron oxide and heat it up, the oxygen will be transferred from the iron oxide to the aluminium once the temperature is high enough. By this it generates very much extra heat that you get a thermic lance.

So one could assume the plating of the ship are build of an alloy that is unstable at high temperatures and that is also extremely strong and stable enough at normal temperatures to be safely used. When heated up it will decompose itself. That would also explain why a simple laser shot not just burns a hole in the hull but always seems the disintegrate the whole ship. Once the chain reaction starts, the whole hull burns away. Only interior parts made of normal alloys survive. e.g. the fridge.
You, sir, are a freaking GENIUS. Forged titanium alloys have what is known as a weak beta-phase at around 1000 °C (it turns to liquid at 1668 °C). Heating it to the right amount leads to a sharp decrease of the plasticity. High plasticity can be restored only by reforging, which is a bit hard to do in the vacuum of space, and under heavy laser fire. So the hull becomes brittle. The liquid metal can then turn into a gas at 3287 °C, so you'd have a mix of solid-but-brittle / liquid molten bits floating around / sudden gaseous alloy parts which will expand rapidly (causing what looks like a fireball). So even the little bits floating around are OK, because they're liquid droplets of Ti-alloy that have cooled into a solid droplet again in the cold of space.

Image

And as a powder (or in the form of metal fragments that liquified and re-solidified), titanium metal poses a significant fire hazard. When heated in air, it's an explosion hazard (so once the secondary hull is breached... KABOOM!). Water and carbon dioxide-based methods to extinguish fires are ineffective on burning titanium; Class D dry powder fire fighting agents must be used instead.

Science class over.

How soon are we to getting 1.73? Because I have the good-looking planets. I have Simon's ships. I have Griff's new Cobra III (and I haven't changed the code, because I like the bounty that shooting a fugitive and capturing the Escape Pod provides). I have the HalSis female voice, and I have those lovely Griff Constores (yes, I'm proud of the artwork I've done for the Ad Boards, Ad Rings and animated doo-dahs).

But I want disintegrating Cobras!
"All is for the best in this best of all possible worlds..."
Dr.Pangloss, Voltaire's 'Candide'.

Image
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Is there a way to remove objects without an explosion after a few seconds delay using the objects AI?
I saw the command "this.ship.remove() " mentioned earlier in the thread but that looks like a JScript command, can that be used in an AI?

i've cobbled this AI together, and it works great apart from all the junk fragments go out with a bang,

Code: Select all

{
	GLOBAL = {
	ENTER = ("pauseAI: 15.00"); 
	EXIT = (); 
	UPDATE = (becomeExplosion); 
	}; 
}
i don't want this final explosion to happen - the fragments in question as just tiny 4 polygon rectangles with the dissolving clip map effect on them, and after about 15 seconds they're not being drawn anymore by the shader so they could just vanish from the game silently without the yellow fireball
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

You can give the ship (or fragment in this case) a script, and the have the AI sent the script a trigger to do something with the AI command "sendScriptMessage: <command>".

For example if you have "sendScriptMessage: shipRemove" in the AI and this.shipRemove = function() in the script, the former will cause the js commands associated with the latter (between the {}'s that delimit the function) to be triggered.

If you want an example look in the script I gave you for this, that's how that does it for the spawning of sub-fragments.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Thanks Thargoid! that's working a treat!
Post Reply