Page 7 of 21

Posted: Sun Apr 22, 2007 2:55 pm
by Frame
Image

There :D

Posted: Mon Apr 23, 2007 7:09 am
by TGHC
WTF.

Awesome! but why does it say Krait in the missile indicator?

Posted: Mon Apr 23, 2007 7:25 am
by Uncle Reno
TGHC wrote:
but why does it say Krait in the missile indicator?
Because it always shows the current ship name targeted there when you use your ID system. :)

Posted: Tue Apr 24, 2007 9:13 am
by Griff
y'know, i've never noticed it say the ship name down by the missile indicator before too busy looking at the laser temperature gauge i guess!
anyway, i imagine everyone's pretty tired of seeing this ship by now but i thought i'd post one more screenshot:-
Image
i've been taking the various shaders ahruman wrote for the 'krait' and it's subentities and adding them into one shader, what i thought was cool here is the hot metal glow on the laser cannons and various engine bits at the back of the ship, i thought this might look cool on the alloy fragments left behing by exploding ships? making them look red hot from the laser fire & explosion, i might have a go at it and if it works maybe write it out as a sort-of tutorial ('sort-of' since i'm not really sure what i'm doing!)

Posted: Tue Apr 24, 2007 9:24 am
by Arexack_Heretic
I'm almost expecting you to add homeworld-esque damage effects any minute now. ;)

You are taking these models to a whole new level.

Mucho cudos.

Posted: Tue Apr 24, 2007 9:40 am
by Griff
heh, i dunno that krait is starting to look a bit garish now! i'm going overboard on the effects!
what i'm planning on doing soon is painting out some glow & effects maps for one of the standard ships, putting it all into rendermonkey (and hopefully the open source shader program ahruman linked to a few pages back - 'lumiere'?) and uploading it somewhere for us all to have a tinker with and see what we can come up with - hopefully get a shader version of the 'scripters cove' thread going, although ahrumans recent posting about ship materials will bring all the goodness of shaders into some extra <key>'s that you just add to a ships shipdata.plist file to switch on the effects, all the complex stuff will happen behind the scenes!

Posted: Tue Apr 24, 2007 9:55 am
by Arexack_Heretic
Yes dandilly so. ;)

But remove the outlandish deepsea-hullglow and the heatglow takes on a menacing rather than garish appearance, i bet.

-Started 'Shaders Outpost' thread. -

Posted: Tue Apr 24, 2007 10:45 am
by JensAyton
Griff wrote:
…although ahrumans recent posting about ship materials will bring all the goodness of shaders into some extra <key>'s that you just add to a ships shipdata.plist file to switch on the effects, all the complex stuff will happen behind the scenes!
It’s not gone that far… yet. The material stuff lets you set an overall glow colour for a material, for instance, irrespective of shaders, but it doesn’t allow you to specify a glow map.

Posted: Wed Apr 25, 2007 12:50 pm
by Dr. Nil
Griff wrote:
anyway, i imagine everyone's pretty tired of seeing this ship by now
I'm not :D

Posted: Wed Apr 25, 2007 5:54 pm
by TGHC
Me neither.

Posted: Fri May 04, 2007 9:48 pm
by Griff
i've vandalised Ahrumans laserglow shader into a glowing metal fragment shader for use on debris left behind by exploding ships, here is it at work on the 'alloy' metal fragment:-

Image

I'm trying to get the glow amount to decrease over time, the glow amount is being set by a variable called metal_temperature in the shader code, can this be counted down from 1 to 0 in the shader code?

here's the fragment shader code:-

Code: Select all

// Information from Oolite.
uniform sampler2D      tex0;
uniform sampler2D      tex1;

uniform float         time;
uniform float         metal_temperature;


// Information from vertex shader.
varying vec3         v_normal;      // Surface normal
varying vec3         v_pos;      // Vertex/fragment position in eye space


// Calculates the levels of R, G & B that make up the glow effect (MetalGlow). Red channel in effects map png proportional to level of effect.
vec4 MetalGlow(float level)
{
   vec4 result;
   
   result.rgb = vec3(1.0, 0.5, 0.25) * level; 
   result.a = 1.0;
   
   return result;
}

// Irregular flickering function.
float Pulse(float value, float timeScale)

{
   float t = time * timeScale; 
   float s0 = t;
   s0 -= floor(s0);
   float sum = abs( s0 - 0.5);
   
   float s1 = t * 1.7 - 0.05;
   s1 -= floor(s1);
   sum += abs(s1 - 0.5);
   
   float s2 = t * 2.3 - 0.3;
   s2 -= floor(s2);
   sum += abs(s2 - 0.5);
   
   float s3 = t * 5.09;
   s3 -= floor(s3);
   sum += abs(s3 - 0.5);

   return (sum * 0.25) * value;
}


// Calculate the contribution of a single light. Ought to be a function, but OS X's GLSlang implementation isn't sufficiently clever.
#define LIGHT(idx) \
   { \
      vec3 lightVector   = normalize(gl_LightSource[idx].position.xyz); \
      vec3 reflection   = normalize(-reflect(lightVector, v_normal)); \
       diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \
      specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \
   }


void main(void)
{
   vec4 diffuse = vec4(0.0), specular = vec4(0.0);
   vec3 eyeVector = normalize(-v_pos);
   
   // Load texture data
   vec2 texCoord = gl_TexCoord[0].st;
   vec4 ColorMap = texture2D(tex0, texCoord);
   vec4 EffectsMap = texture2D(tex1, texCoord); 
   float specExponent = EffectsMap.b * 200.0 + 1.0;
   float specIntensity = EffectsMap.g * 1.2;
   
/*   Light 0 is the "showroom" light, used in the demo screen and shipyard.
   Light 0 is currently disabled, because there's no way for the shader to know when it's turned off.
   The solution for this will probably be for Oolite to set its diffuse and specular components to
   black when it's not being used.
   
   Light 1 is the sun.
   */
#ifdef OO_LIGHT_0_FIX
   LIGHT(0);
#endif
   LIGHT(1);
   diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient;    
   specular = mix(specular, specular * diffuse, 0.0);
   vec4 color = diffuse * ColorMap + specular * specIntensity;
   
   
   
   float HeatAlphaR = EffectsMap.r * 2.0; 
   float HeatAlphaB = EffectsMap.r * 0.05; 
   
   color += MetalGlow(metal_temperature * HeatAlphaR + HeatAlphaB);
   
   // ...and heat effects
   float Heat = max(metal_temperature - 0.5, 0.0) * 2.0;
   Heat = Pulse(metal_temperature, 0.1); 
   float Heat2 = Pulse(metal_temperature, 0.5); 
   float turnuptheheat = ((Heat + metal_temperature * HeatAlphaR) * HeatAlphaB) + ((Heat2 + metal_temperature * HeatAlphaB) * HeatAlphaR);     
   color += MetalGlow(turnuptheheat);
    
   gl_FragColor = vec4(color.rgb, 1.0);
}

Posted: Fri May 04, 2007 10:09 pm
by JensAyton
Griff wrote:
i've vandalised Ahrumans laserglow shader into a glowing metal fragment shader for use on debris left behind by exploding ships, here is it at work on the 'alloy' metal fragment:-
Nice!
Griff wrote:
I'm trying to get the glow amount to decrease over time, the glow amount is being set by a variable called metal_temperature in the shader code, can this be counted down from 1 to 0 in the shader code?
No. However, in 1.69 or 1.70 this will be possible by setting the initial time (as a uniform) in the “ship script” for the fragment. This’ll involve something along the lines of:

Code: Select all

// Ship script (JavaScript):
this.didSpawn = function()
{
    this.setShaderUniform("startTime", time);
}

// Shader (GLSL):
uniform float time;
uniform float startTime;
// ...
float elapsedTime = time - startTime;
The details of the JavaScript bit here haven’t been determined yet, but should look about like that. The setShaderUniform method will probably set a uniform for every material in the ship/entity and all subentities. There will probably also be a bindShaderUniform method to bind a uniform to a ship property.

Come to think of it, a shader-bindable spawnTime uniform might be a more elegant solution.

Posted: Sat May 05, 2007 7:38 am
by Jakob Kramer
Griff wrote:
i've vandalised Ahrumans laserglow shader into a glowing metal fragment shader for use on debris left behind by exploding ships, here is it at work on the 'alloy' metal fragment
Ooh! That looks nice!

A cool (but probably not easily implemented) effect could be if such a "heated metal glow" could be added to the places a ship's hull was hit during combat. That is, the more hits it takes the more the hull glows (ideally at those points the hull was hit).

Posted: Sat May 05, 2007 11:00 am
by JensAyton
Not gonna happen any time soon, I’m afraid.

Posted: Sat May 05, 2007 1:17 pm
by Commander McLane
@ Griff: very, very nice. And it will definitely make it easier to locate all those fragments after you have blown up some ship. :twisted:

:D :D :D