Griff's normalmapped ship remakes

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

Moderators: winston, another_commander

UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Post by UK_Eliter »

A wonderful response! I shall give it a go (test it out) in a little while. Thank you very much.
User avatar
Simon B
---- E L I T E ----
---- E L I T E ----
Posts: 836
Joined: Thu Oct 23, 2008 5:54 am
Location: Red Beach NZ
Contact:

Post by Simon B »

ZygoUgo wrote:
@Simon.. Glad to see you about, and that's a very scrummy return. Any thoughts about helping update other willing OXP's to fit Griffs' stylings? Your ships are more than welcome in my Ooniverse :wink:
Well gee shucks.

I'm studying griffs shader style and should be able to put together a basic howto. The trick is to use the shader tag off a griff ship that looks sort of the same style you want for the ship you are working on -- that way you don't need to understand how the things actually work. Replace the texture names with yours... these are png files you provide for your ship just like the regular skin.

The skin is done as normal... griff ships have simple color schemes in there though because the shader handles the fancy stuff - so it is dark greys mostly and anything that will be the same in all ships of this type.

The normalmap is also the same as the neolite one - but griff likes to use the alpha channel for information, same with the skin, that's why the textures directory is full of "air".

The information layers work a bit like the effects map for neolite - only the encoding is different. Draw each one in greyscale, seperately, keep a copy of each and combine them to color channels in the final png. Different ships do things slightly differently. So far the sidewinder player version shaders look like the easiest to use.

The model itself is kept boxy - but griff likes to put a spine along the top. For the FDL I worked that into the engine and split the points. And, yes, I have an NG edition in mind. The above won't work for an NG edition of the one currently in the oxp. The FDL is actually the hardest model to redo because its all sharp corners ... the normalmaps don't wrap around corners too well which is probably why griff's tend to follow them more. (They also don't seem to render well close up or in the views.)
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2481
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Updated the asteroid test oxp to add in some some trippy space glow stuff on some of the rocks
Image
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post by Cody »

They're certainly 'trippy', Griff... rather nice, in fact.
They throw up a whole bunch of these in the log, though:

Code: Select all

[shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for griff_glow_moss_asteroid.fragment:
>>>>> GLSL log:
Fragment shader failed to compile with the following errors:
ERROR: 1:112: error(#202) No matching overloaded function found mix
ERROR: error(#273) 1 compilation errors.  No code generated


[shader.load.fullModeFailed]: ----- WARNING: Could not build shader griff_glow_moss_asteroid.vertex/griff_glow_moss_asteroid.fragment in full complexity mode, trying simple mode.
  [shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for griff_glow_moss_asteroid.fragment:
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Have you been peaking in my WiP folder again, Griff? :P

Seriously thought, looks wonderful. Can't wait to see the whole thing. One note however, asteroids are too small to have sufficient mass for thermodynamic reactions.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2481
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

El Viejo wrote:
They throw up a whole bunch of these in the log, though:

Code: Select all

[shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for griff_glow_moss_asteroid.fragment:
>>>>> GLSL log:
Fragment shader failed to compile with the following errors:
ERROR: 1:112: error(#202) No matching overloaded function found mix
ERROR: error(#273) 1 compilation errors.  No code generated


[shader.load.fullModeFailed]: ----- WARNING: Could not build shader griff_glow_moss_asteroid.vertex/griff_glow_moss_asteroid.fragment in full complexity mode, trying simple mode.
  [shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for griff_glow_moss_asteroid.fragment:
Drat, i didn't test properly, i think it's this line in the fragment shader

Code: Select all

color+= mix(gloweffect, 0.0, (LightLevel + Terminator) * InvTerminator);
That 0.0 is wrong, it should be a vec3(0.0) like this:-

Code: Select all

color+= mix(gloweffect, vec3(0.0), (LightLevel + Terminator) * InvTerminator);
but on closer inspection, the tags for chopping up the shader into simple and full shader mode aren't in there, i'll re-do that shader and re-upload the oxp

edit: Ok, i've reuploaded the oxp with the edited shader, if you want to save yourself another download, open griff_glow_moss_asteroid.fragment in a text editor, clear out the code in there and replace it with this

Code: Select all

uniform sampler2D    uColorMap; // Diffuse & Effects mask
uniform sampler2D    uNormalMap; // normal map & specular intensity map
uniform sampler2D    uCamoNoise; // effects for the swirly camo cloud stuff

varying vec2         vTexCoord;
varying vec3         vEyeVector;   // These are all in tangent space
varying vec3         vLight0Vector;
varying vec3         vLight1Vector;
varying float LightLevel;
   
// Constants
const float KspecExponent = 15.0;
const float k2Pi         = 6.283185307179586;
const float kTimeRate      = 0.2;
const float uSharpen = 8.0;
const float Terminator = 0.3;
const float InvTerminator = 1.0 / (2.0 * Terminator);

// Uniforms from Oolite
   uniform float  uTime;
   uniform float  hull_heat_level;
   uniform float  uPersonality;
   
// Select between two camo colours
float CamoEffect(sampler2D texture, vec2 vTexCoord)
{
   float n1, n2, n3, n4;
   float time = uTime * uPersonality;

   n1 = texture2D(texture, vTexCoord + vec2(0.01, 0.005) * time).r;
   n2 = texture2D(texture, vTexCoord + vec2(0.013, -0.02) * time).g;
   n3 = texture2D(texture, vTexCoord + vec2(-0.008, 0.017) * time).b;
   n4 = texture2D(texture, vTexCoord + vec2(-0.019, -0.151) * time).a;
   
   n1 = sin(n1 * k2Pi + time);
   n2 = sin(n2 * k2Pi * 3.0 + time * 1.003) * 0.5;
    n3 = sin(n3 * k2Pi + time * 2.0);
    n4 = sin(n4 * k2Pi + time * 3.337);
   
   // 7.0 is the total magnitude of n1..n4 times two.
   float scaledSharpen = uSharpen / 7.0;
   
   float n = (n1 + n2 + n3 + n4);
   return smoothstep(0.0, 1.0, n * scaledSharpen);
}

// Irregular flickering function
   #ifndef OO_REDUCED_COMPLEXITY 

// Hull Temperate heat glow effect
     vec3 TemperatureGlow(float level) 
     { 
        vec3 result = vec3(0); 
    
        result.r = level; 
        result.g = level * level * level; 
        result.b = max(level - 0.7, 0.0) * 2.0;
        return result;    
     } 
#endif

void Light(in vec3 lightVector, in vec3 normal, in vec3 lightColor, in vec3 eyeVector, 
           in float KspecExponent, inout vec3 totalDiffuse, inout vec3 totalSpecular)
{
   lightVector = normalize(lightVector);
   vec3 reflection = normalize(-reflect(lightVector, normal));
   
   totalDiffuse += gl_FrontMaterial.diffuse.rgb * 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.rgb, eyeVector, KspecExponent, diffuse, specular)

void main()
{
   vec3 eyeVector = normalize(vEyeVector);
   vec3 normal = normalize(texture2D(uNormalMap, vTexCoord).rgb - 0.5); 
   vec3 colorMap = texture2D(uColorMap, vTexCoord).rgb;
   vec3 diffuse = vec3(0.0), specular = vec3(0);
   float specIntensity = texture2D(uNormalMap, vTexCoord).a;

#ifdef OO_LIGHT_0_FIX
   LIGHT(0, normalize(vLight0Vector));
#endif

   LIGHT(1, normalize(vLight1Vector)); // change the 0 to 1 when exporting back to oolite
   diffuse += gl_FrontMaterial.ambient.rgb * gl_LightModel.ambient.rgb;
   float cycletime =  uTime * uPersonality; 
   vec3 color = diffuse * colorMap + colorMap * specular * specIntensity * 2.0;
   vec3 CyclingIllumCol = vec3(clamp(sin(cycletime * 0.5),0.0, 1.0), clamp(sin(cycletime * 0.25), 0.0, 1.0), clamp(sin(cycletime * 0.125), 0.0, 1.0));  
   float mask = texture2D(uColorMap, vTexCoord).a;

 #ifndef OO_REDUCED_COMPLEXITY    
// these next glow effects are only available in full shader mode   

   float camoSelect = CamoEffect(uCamoNoise, vTexCoord);
   vec3 camo1 = CyclingIllumCol;
   vec3 camo2 = CyclingIllumCol * 2.0;
   camo2 = camo2 * camo2;   // camo foreground, sun-coloured with increased saturation
   vec3 camo = mix(camo1, camo2, camoSelect);  
   vec3 gloweffect = camo * mask;

  
// fully dark
    if (LightLevel < -Terminator)
    {
    color += gloweffect; 
    }      
        
// within the twilight zone, mix 
    if (abs(LightLevel) < Terminator )
   {
        color+= mix(gloweffect, vec3(0.0), (LightLevel + Terminator) * InvTerminator);
   }   
   
// Add the all over hull temperature glow. Full Shader mode only
   float hullHeat = max(hull_heat_level - 0.5, 0.0) * 2.0; 
   color += TemperatureGlow(hullHeat); 
#endif   

// do a simpler glow effect for simple shader mode
#ifdef OO_REDUCED_COMPLEXITY 
color += mask * CyclingIllumCol;
#endif  
    
   gl_FragColor = vec4(color.rgb, 1.0);
}
DGill
---- E L I T E ----
---- E L I T E ----
Posts: 292
Joined: Thu Jan 01, 2009 9:45 am

Post by DGill »

Those asteriods look so good - outstanding work Griff
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post by Cody »

Thanks Griff.
Cmd. Cheyd wrote:
One note however, asteroids are too small to have sufficient mass for thermodynamic reactions.
How about ultra-dense 'unobtanium'.

In fact, you could make them quite rare, and difficult, dangerous but rewarding to mine… add the capability to mass-lock, due to density/mass, perhaps… an interesting addition?
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
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 »

Griff wrote:
been mucking about with some dry cracked earth textures and the parallax shader, .... although once again i've UV unwrapped these really badly - some clearly visible and horrible seams in the texture which the parallax makes even worse !
Its not the problem that you wrapped it wrong. The problem is that it will never be possible to UV wrap a seamless tiled map fully around an object. There will always be an area were the joints don't fit. For wrapping a single texture, seamless around an object you will need something like a lat-long map to start with.
With Charlie's asteroids I cheated badly by using a mirrored texture at the other half of the asteroids. That way you can wrap any texture file around the asteroids, but when examining the asteroids closely you will always see the mirror band. And the normal map of the mirrored side will be inverted. :?
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

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

Post by Griff »

proof that not all experiments work out well, the 'iceteroid' :-
Image
http://www.box.net/shared/apoq0kl2oi

Don't think these are going to make the oxp, i'm aiming for reflective ice boulders with frosty patches on them, i've hacked a horribly mangled version of the glitter shader from rendermonkey into it (without the random noise texture it uses to help randomise the glitter effect - so you will see the sparkles form odd symmetrical patterns at some angles)
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post by Cody »

Took Rolling Thunder out to look at one, and launched straight into a nasty furball (that oxp is great).

The ‘iceteroid’ looks really strange in-game… sort of a weird, hollow 'pattern' under the ‘ice’… very odd!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post by Cody »

Those asteroids are seriously freaky, Griff… I like.

Pics of the same ’roid, a second apart:

Image Image
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
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 »

El Viejo wrote:
Those asteroids are seriously freaky, Griff… I like.

Pics of the same ’roid, a second apart:

Image Image
Asteroids? I thought it were Thargoid cocoons, disguised as asteroids. :lol:
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2481
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

yeah, i thought i'd have a bit of a play around making some colourful ones, i'll probably make these glowing ones rare, it'll be boring if every asteroid is the trippy type, it'll be cool if they could spawn in clusters of the same type, I'll have to ask the scripting wizards if this is possible, oo, and maybe make them 'unstable' so they pop excitingly if you shoot at them :D What do you think about the glow colours? should they cycle through the whole spectrum, or should they just pick one shade and stick to that, getting brighter and fainter?

yeah, the iceteroid swirly effect isn't really working in this case, it's a copy of the liquid metal effect another_commander discovered and demo'd ages ago on the forum, it comes from giving the parallax shader too high a scale & bias value, i thought it might give a feel of ice refracting the light and contrast nicely with the more traditional frosty bits on the rock, but it looks more like some wierd graphics glitch :lol: Maybe a bit more care with the texture maps might help, it's just using some quickly cobbled together ones at the moment
Post Reply