Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

RFC: Fancy classics

General discussion for players of Oolite.

Moderators: winston, another_commander

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 »

DaddyHoggy wrote:
I don't understand hardly any of this and yet find it completely compelling at the same time...
Don't you just love the octarine words dancing in the air?

... I actually understood that! I must be getting back into the swing of this coding lark.

Seems I'm actually using the wrong Light() entirely - i.e. not the one I posted. I'll change it, check it, and post the entire thing for prosperity.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Simon B wrote:
The method used to produce the oldships.oxp set was pretty formulaic - only the cat and salamander do not use the formula.

If you want to use this set but worry that your fav ship will clash (or you have an oxp you want to modify to fit in... or you just want to be able to model: have a look.)
Hmmm. This reads to me as if the package is available already, but I was unable to find it. Did I get it wrong or have I been too blind to find it?

About your BCC: I was astonished when I switched to aft view. Front view has a part of the ship visible, just enough to provide background for the HUD, which is nice. Aft view however is positioned below the BCC and has the BCCs body completely hide the upper part of the HUD, from the center of the crosshairs, which results in aft lasers being pretty useless.

Screet
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 »

All new errors:

Code: Select all

[shader.link.failure]: ***** GLSL shader linking failed:
>>>>> GLSL log:
Fragment info
-------------
(111) : warning C7011: implicit cast from "vec4" to "vec3"
(111) : warning C7011: implicit cast from "vec4" to "vec3"
(111) : warning C7011: implicit cast from "vec4" to "vec3"
(111) : warning C7011: implicit cast from "vec4" to "vec3"
(111) : warning C7011: implicit cast from "vec4" to "vec3"
(111) : error C1035: assignment of incompatible types
(111) : error C5210: assignment among incompatible concrete types
(0) : fatal error C9999: unable to generate code, no legal types for program.
The warnings tell me that I have a vec3 = vec4, 5 times. But the machine can cope with it - presumably by dropping the last component.

But those last two?? It would help if I had some hint as to where they are encountered.

Current fragment shader

Code: Select all

// Information from Oolite.
uniform sampler2D      uColorMap; // Diffuse and Specular Intensity map
uniform sampler2D      uFXMap; // Effects & Light Illumination Map
uniform sampler2D      uNormalMap; // Normal Map

const float specExponent = 5.0;
uniform vec3    SpecularRGB;
uniform float   time;
uniform float   eng_pow;
uniform float   hull_heat;

// Information from vertex shader.
varying vec2         vTexCoord;
varying vec3         vEyeVector;   // These are all in tangent space
varying vec3         vLight0Vector;
varying vec3         vLight1Vector;

// redGlow effect
vec4 redGlow(float level)
{
   vec4 result;
   result.rgb = vec3(1.9, 0.5, 0.2) * level * 2.0;
   result.a = 1.0;
   return result;
}

// EngineGlow effect
vec4 EngineGlow(float level)
{
   vec4 result;
   
   result.rgb = vec3(1.9, 0.5, 0.20) * level;   
   result.a = 1.0;
   
   return result;
}

void Light(in vec3 lightVector, in vec3 normal, in vec4 lightColor, in vec3 eyeVector,
           in float specExponent, 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), specExponent);
} 

#ifdef OO_REDUCED_COMPLEXITY
#define Pulse(v, ts) ((v) * 0.95)
#else
// 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 * 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.1 + 0.9) * value;
}
#endif

// 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, vector) Light(vector, normal, gl_LightSource[idx].diffuse, eyeVector, specExponent, diffuse, specular)

void main()
{
   vec4 diffuse = vec4(0.0), specular = vec4(0);
   vec3 eyeVector = normalize(vEyeVector);
   vec2 texCoord = vTexCoord;

   // Load texture data
   vec4 colorMap = texture2D(uColorMap, texCoord);
   vec4 fxMap = texture2D(uFXMap, texCoord);
   vec3 normal = normalize( texture2D(uNormalMap, texCoord).xyz - 0.5);
   normal = normalize(normal);

   float specIntensity = 15.0 * colorMap.a * colorMap.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 * gl_LightSource[0].ambient;
   diffuse += fxMap.a; // use fxmap alpha channel as an illumination map 

   
   vec4 color = diffuse * colorMap;
   color += redGlow(fxMap.b * Pulse(min(eng_pow, 1.0), 1.0)); // adds red 'engine heat' glow
   color += EngineGlow(fxMap.r * eng_pow); // adds orange/red exhaust-vent glow
   
// calculate the specular, colour it using a weighted sum of diffuse map and imported color 
   color += 3.0 * ((0.7*SpecularRGB)+(0.3*colorMap)) * specular * specIntensity;
   color.a = 1.0;
   
   gl_FragColor = color;
}
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
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 »

Too late at night to read code, but:
Simon B wrote:
The warnings tell me that I have a vec3 = vec4, 5 times. But the machine can cope with it - presumably by dropping the last component.
Actually, implicit casts are illegal and those warnings should be errors. Typically you want vec3 x = y.rgb (or equivalently y.xyz).
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 »

The problem is here:

Code: Select all

color += 3.0 * ((0.7*SpecularRGB)+(0.3*colorMap)) * specular * specIntensity;
... if I remove the SpecularRGB bit, all errors vanish. It is explicitly vec3 but color is vec4 - how to fix? For now I have made it explicitly vec4 and must remember to put the fourth channel = 1.0 in the plist.

Now I have a very shiny ship... and no normalmap effects. Grrr...

No window lights and no engine-glow, no errors about the effects map.

Setting the glow-effect to nil stops the madly shiny look. (Its the alpha channel in the effects map - so that must be loaded fine ... perhaps I should invert it so max alpha (=1?) is zero glow?

Anyway - fiddle time...
I notice the griff boa has things like

Code: Select all

      uniforms =
      {
	uColourMap = { type = texture; value = 0; };
	uFXMap = { type = texture; value = 1; };
	uNormalMap = { type = texture; value = 1; };
... in the uniforms - dunno why and adding them makes not a snot of difference.

I've painted garishly over the effectsmap - so there is red and blue over easily observed bits. On the wings - blue comes out dark and red comes out light.

Perhaps everything is being loaded, but the effects get washed out for some reason?


BTW: I have had a reply from the developer of the GIMP normal-map plugin.
He says he wants to implement custom meshes as a feature since it's been requested so many times. He's asked for help, which must be where everyone else backs down.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
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 »

Discovered - the uniform inside the fragment shader needs the same name as the uniform in the plist to work - silly me.

So I now see an engine effect over the entire model ... grrr... when will this madness end?!

Well ... the engineglow stuff now reads:

Code: Select all

// EngineGlow effect
vec4 EngineGlow(float level)
{
	return vec4(vec3(0.9, 0.5, 0.2) * level, 0);
}
and main() now looks like this:

Code: Select all

void main()
{
   vec4 diffuse = vec4(0.0), specular = vec4(0);
   vec3 eyeVector = normalize(vEyeVector);
   vec2 texCoord = vTexCoord;

   // Load texture data
   vec4 colorMap = texture2D(uColorMap, texCoord);
   vec4 fxMap = texture2D(uFXMap, texCoord);
   vec3 normal = normalize( texture2D(uNormalMap, texCoord).xyz - 0.5);
   normal = normalize(normal);

   float specIntensity = 0.5 * colorMap.a * colorMap.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 * gl_LightSource[0].ambient;
   //diffuse += fxMap.a; // use fxmap alpha channel as an illumination map

	specular = mix(specular * SpecularRGB, specular * colorMap, 0.0); // Adds the Specular Effect 

	// Add in constant glow (blue on effects map)
	diffuse += fxMap.b;
	
	// Apply part of engine effect before applying colour, so it is partially texture-dependant
	float engineAlpha = fxMap.r;
	vec4 engineEffect = engineAlpha * EngineGlow(min(uEngineLevel, 1.0));
	diffuse += 0.4 * engineEffect;

   
   vec4 color = diffuse * colorMap + specular * specIntensity;

	// Apply rest of engine effect
	color += 0.6 * engineEffect;

   	// ...and heat effects
	float hullHeat;
	hullHeat = max(uHullHeatLevel - 0.5, 0.0) * 2.0;
	hullHeat = Pulse(hullHeat * hullHeat, 0.1);
	color += redGlow(hullHeat);

   color.a = 1.0;
   
   gl_FragColor = color;
} 
... which is how I handled the effects for the arachnid.

Now that gives me an engine glow varying with speed over the entire ship - except, it vanishes completely at max speed. The glow is clearly not confined to the red parts of the fxMap.

Similarly, I don't see any constant glow from the blue part. (Checked this inside a planets shadow just to be sure.

<sigh> if I'm reading the signs right, it's time to think about something else for a bit... it's the 13th over here you know. Hey ... is'nt the World supposed to end tonight? I can almost believe it - it was 37.4C yesterday.

Anyway, that would kind of get me off the hook with the wife tomorrow ;)
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
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:

Neolite Companion OXP preview 1 ready

Post by Simon B »

Neolite Companion
... this is now ready for perusal. (hint: click the title...)

Everything should go except for shaders, views, and some exhausts.
So treat it as late beta.

Is not compatible, and will not work with, oldships.oxp. Will override aegidian-specials.

Includes all the oldships oxp craft with the mussurana as a bonus.
I hope the various authors take this as the compliment intended.

If you'd like to see a particular craft in dire need of an update in the companion, let me know. Ships from oxps under active development will not be considered, unless the oxp maintainer asks me.

I'd like to have a go at the ships built-in to random hits and navy ...
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
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 »

Simon B wrote:
I notice the griff boa has things like

Code: Select all

      uniforms =
      {
	uColourMap = { type = texture; value = 0; };
	uFXMap = { type = texture; value = 1; };
	uNormalMap = { type = texture; value = 1; };
... in the uniforms - dunno why and adding them makes not a snot of difference.
That looks a bit wrong – the FX map and normal map are mapped to the same texture. If you’ve copied that, it’d explain why the effects aren’t working as expected…
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Neolite Companion OXP preview 1 ready

Post by JensAyton »

Simon B wrote:
Neolite Companion
... this is now ready for perusal. (hint: click the title...)
Er… you can’t put an OXP inside an OXP. :-) (People generally shouldn’t be expected to look inside a folder named foo.oxp to find the OXP hiding in it, and on Mac OS X it looks like a file.)
ovvldc
---- E L I T E ----
---- E L I T E ----
Posts: 344
Joined: Sat Apr 02, 2005 9:32 am
Location: Netherlands

Re: Neolite Companion OXP preview 1 ready

Post by ovvldc »

Simon B wrote:
I'd like to have a go at the ships built-in to random hits and navy ...
There really is no stopping you, is there? 8)

Just to recap: this includes the ships from Old Ships, Aegidians's Specials. It does not include Aegidian's X-Ships or New Ships. I think it would be best to replace ships on a per-oxp basis, so that players can make a clean switch...

I am a bit fuzzy on whether you want to do with the Behemoth, Military Fiasco (Navy stuff), Murgh's X-ships (used in Military Fiasco), Python Class Cruiser and/or maybe the Mpack rusties.

It could be nice to have really shiny versions, the slightly smudged ones that you made and some really rusty and downspecced versions. The visual difference should be in the paint textures only, not in normals maps or other stuff (perhaps scale up the shine on the pristine versions and scale down the shine on the rusties)..

Not that I think you haven't done a beautiful job already.... :!:

Best wishes,
Oscar
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 »

bushmaster_auv.png is 512 × 514 pixels and will be rescaled each time it’s loaded. I suspect you don’t really want the two rows of white at the bottom.

OXP verifier sez: “WARNING: model "neocat.dat" could not be found in neolite-companion.oxp or in Oolite.”
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 »

Ahruman wrote:
That looks a bit wrong – the FX map and normal map are mapped to the same texture. If you’ve copied that, it’d explain why the effects aren’t working as expected…
Ah - the value part is an index - that makes sense now ... of course had I actually read the specification, I'd know that ... but that would be... reading ... the ... instructions ... and where's the fun in that?

Anyway, that did the trick - but how come the engine glow hits zero at maximum speed? Probably that max thing ...
Er… you can’t put an OXP inside an OXP. :-) (People generally shouldn’t be expected to look inside a folder named foo.oxp to find the OXP hiding in it, and on Mac OS X it looks like a file.)
But ... I didn't. The file linked to is

neolite-companion.oxp.tar.gz

like always
- inside the tarball there is a readme and an oxp.
- inside the oxp are the usual directories.

sometimes an archive manager will create a directory for the contents of the unpacked archive ... it names the directory after the archive name with the .tar.gz stripped off.

If you'd opened the archive in the viewer and dragged the contents out you wouldn't have had that problem - and this option is why I don't just put the oxp content in the top of the archive.

I think you can alter the unpack options so a new directory does not get created.
Er… you can’t put an OXP inside an OXP. :-) (People generally shouldn’t be expected to look inside a folder named foo.oxp to find the OXP hiding in it, and on Mac OS X it looks like a file.)
grrr... there's always something ... autocrop and resave that png will fix that - it doesn't throw the texture off in the preview.

I've been watching the cat in the preview ... but wait: there's two! The dat is called neocougar.dat and I probably only changed it in one.

I've also changed the name to Cat MkII - to reflect the dramatic shape change. But ... is there already a cat mkII (the regular one is cat mkI)

The final release will change a lot of names anyway, so there are fewer clashes outside the intended replacements.

Ho hum .. back to Valentines.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
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:

Re: Neolite Companion OXP preview 1 ready

Post by Simon B »

ovvldc wrote:
Simon B wrote:
I'd like to have a go at the ships built-in to random hits and navy ...
There really is no stopping you, is there? 8)
Oh sure - there's always money and sex... from you I'll take cash.

I think it would be best to replace ships on a per-oxp basis, so that players can make a clean switch...
So far the Mussurana is a one-off and I hesitate to ask the board where best to put it because that may be a bit tempting ;)

I am a bit fuzzy on whether you want to do with the Behemoth, Military Fiasco (Navy stuff), Murgh's X-ships (used in Military Fiasco), Python Class Cruiser and/or maybe the Mpack rusties.
The trouble with this project is that it affects a lot of other add-ons.
The navy ships, though nice, always clashed horribly with the rest of the game ... otherwise the oxp is a great addition to the gameplay.

MPack Rusties are a case in point - if you want to follow earlier suggestions and keep the standard ship set in place as "classic" designs - that can be arrainged. In which case, the neolite ships are updated editions and it goes very well with the rusties as they are.

However, in case you want to replace the ships entirely - then ZygoUgo is working at rusting them up as fast as he can. So - rusties will have a neolite version... and you'll want to match the existing rusties with the classic set.

I expected the python-class-cruiser would be a ship asked for - there are issues in translating the design - go look at the neopython again. But not insurmountable. I'd rather not just use the formula method here.
It could be nice to have really shiny versions, the slightly smudged ones that you made and some really rusty and downspecced versions.
In the pipeline - it would be appropriate to have a few chosen ships appearing in as-new condition at a higher price but otherwise no different. There is a pristine model FDL in the pipline...
The visual difference should be in the paint textures only, not in normals maps or other stuff (perhaps scale up the shine on the pristine versions and scale down the shine on the rusties)..
I can do a lot with the shine - yes :D

I'll have to work out how to do the specular better - perhaps putting the specintensity in the green of the effects map and using inverse-alpha in the diffuse map to specify illumination. This will make it easier for third-parties to make their own skins (if the textures are not mostly transparent you see...)

I think it's important not to complicate the models so much that normal people cannot make simple changes to suit themselves.
Simon Bridge
[re2dux] [neolite]
"Everything is perfect down to every last flaw..."
HBT: The Book of Verse - Principia Discordia
User avatar
KZ9999
Deadly
Deadly
Posts: 225
Joined: Fri Jan 23, 2009 8:55 pm
Location: Lost in Witchspace being hunted by a Thargoid Swam.

Post by KZ9999 »

Wow, Simon B the quality of your work just blows me away! :shock:

If you wanted to have a go at some other designs which aren't already in the Ooniverse, how about the ships from the Elite 2 and Archimedes Elite. You have captured one of them with the Cat/Cougar from Elite 2.

If you need the source models, you can download VRML files from here:
http://mackayj.doosh.net/arcships.html. As for the technical specs of each ship, I haven't been able to find them for the life of me. Perhaps the community could have a bit of a dig to see if they have any info on them.

These designs deserve to live on, and you seem to be the guy to bring them back to life.
KZ999's Oolite documents, including the new draft Oolite Game Manual, can be found at www.box.net
User avatar
Star Gazer
---- E L I T E ----
---- E L I T E ----
Posts: 633
Joined: Sat Aug 14, 2004 4:55 pm
Location: North Norfolk, UK, (Average Agricultural, Feudal States,Tech Level 8)

Post by Star Gazer »

You know, with all these splendid new models from Simon, I really think Griff's beautiful Boa ought to be given an entirely different, suitably menacing, new name. It really ought to be something military, like a Dreadnought, or maybe Nebuchadnezzar... ...or something like that...
Very funny, Scotty, now beam down my clothes...
Post Reply