Ruining the classics (screenshot heavy thread)

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

Moderators: another_commander, winston

User avatar
Uncle Reno
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 648
Joined: Mon Apr 24, 2006 12:54 pm
Location: UK

Post by Uncle Reno »

Well, the Wiki describes the Krait as a fighter so I wouldn't say that the colour is necessarily a problem, IMO. In my mind a ship that was going to be used as a fighter wouldn't be a bright colour, it might have lots of flashers for when it wants to be seen but it would want to be hard to hit by being hard to see.
And as LittleBear says, I think it should be a Krait mk.II.
"Get back or I unleash my lethal spotted batoid!!"

What I do when not reading the Oolite bulletin board!

User avatar
ramon
---- E L I T E ----
---- E L I T E ----
Posts: 346
Joined: Thu Jun 01, 2006 2:38 pm
Location: Tavistock
Contact:

Re: Ruining the classics (screenshot heavy thread)

Post by ramon »

Griff wrote:fully kitted out the model comes in at a whopping 1270 polygons (!)
Is that including sub-entities because I always thought there was a limit of about 500?

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2298
Joined: Fri Jul 14, 2006 12:29 pm
Location: Wales

Post by Griff »

i think the main ship and each associated subentity can be up to something like 512 polys, i'm not sure how many subentities you can add, this ship has about 9 - 2 for the hull, 2 for each laser, 1 each for the scoop, fuel injectors, energy unit & naval energy unit and finally 1 more for the rocket exhaust thing at the back, (i chopped it off the hull and added it as a subentity so it can use a smaller effects glowmap)

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 »

Shadificated.

I hit a snag, though: subentities don’t inherit things like engine level and laser heat from their parent. (It seems laser heat stays at zero and is presumably passed on to the parent when shooting.) This should be easy to fix, but obviously that won’t help you until 1.69 comes out. :-) Engine-controlled glows on skins 3 and 4 work, though. Also, all parts of the ship have per-pixel lighting with a subtle specular highlight… which I’d intended to make less subtle before posting, but forgot. If you care, open each fragment shader and find this line:

Code: Select all

vec4 color = diffuse * colorMap + specular * 0.1;
Change the 0.1 to, say, 0.2. (The factor 40.0 in the LIGHT() macro controls the width of the highlight; 128 is pretty tight, 1 is very wide.)

In order for the highlight to be consistent, even the parts of the ships that don’t have effect maps have a shader applied.

Due to a deep-rooted technical limitation in Oolite, each shader replaces a texture, and can’t use that texture itself. This effectively means that if a model is to work on systems without shader support, it must have a separate non-shader texture. One might as well bake effects into it, so I’ve done that for the glows on skin_3&4 and energyunits (but forgot to do it for the laser).

I rearranged things so that no shader needs more than two textures. In particular, I put the beam laser’s laser glow channel in the blue channel if its glow map, and use green * 0.6 for the blue component of the constant glow. This results in no visible difference, but obviously that’s due to the specifics of this particular glow map; it could be done for any map with only two chroma [hue + saturation] values, but not for full RGB colour.

The limits, again – you people really should write this down. ;-)
  • Maximum number of vertices per entity: 320
  • Maximum number of faces per entity: 512
  • Maximum number of textures per entity: 8
  • Maximum number of vertices per face: 16

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 »

Hmm… it seems that the included JavaScript version of the classic spawn-at-witchpoint-for-testing script also demonstrates how much easier it is to track down errors in JavaScript than in plists. Handy, eh? :-)

Oh, and the subentity property thing was easy to fix, although the laser heat calculation for non-player ships appears to be bogus.

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2298
Joined: Fri Jul 14, 2006 12:29 pm
Location: Wales

Post by Griff »

ahruman, wow! thank you so much for taking the time to code up these shaders, the glow effects and specularity are amazing! i've just been wheeling around in a shady cobra just watching the sunlight glint off its hull! by the way can the shaders use specularity maps to control this effect?

here's a screenshot of a glowy 'krait', seeing the hull lights on the blue version ramp up to blazing white when the ship used it's injectors nearly brought a tear to my eye, i can't wait to see what the other oxp-ers are going to do with this effect, Charlie and the Benulobiweed.inc ships especially! Are the shaded ships supposed to have such a strong blue/purple tint? it's a cool effect that varies depending on the ships orientation, is it a new ambient light effect? or something wrong with my graphic card :) I saw this blue tint on the shady cobra too even when they're displaying on the startscreen.
Image

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 »

Griff wrote:ahruman, wow! thank you so much for taking the time to code up these shaders, the glow effects and specularity are amazing! i've just been wheeling around in a shady cobra just watching the sunlight glint off its hull! by the way can the shaders use specularity maps to control this effect?
Yes. Could someone send me a decent specularity map already? :-)

It’s worth noting that the meaning of “specularity map” depends on the lighting model being used. The shaders I’ve written are based on the standard OpenGL model, where specular reflections are defined by two values: “shininess”, or specular exponent, and colour (which sets the intensity of the reflection). In the Krait shaders, the exponent is 40, and the colour is (0.1, 0.1, 0.1), or (0.2, 0.2, 0.2) if you made the change I suggested above.

Generally, white specular effects give a plastic (or glass, or varnished) look, while using the same colour as the diffuse map gives a metallic effect. One way of doing it would be to have one channel for intensity, one for exponent, and another to fade between “plastic” and “metal”. The simplest way is to use a single channel for intensity and exponent.
Griff wrote:here's a screenshot of a glowy 'krait', seeing the hull lights on the blue version ramp up to blazing white when the ship used it's injectors nearly brought a tear to my eye,
Ahh, that’d be a bug of sorts in the shader, but I suppose it can stay in. If NPCs could hyperspeed, there might be a problem.
Griff wrote:Are the shaded ships supposed to have such a strong blue/purple tint? it's a cool effect that varies depending on the ships orientation, is it a new ambient light effect?
Hmm, no. Hard to diagnose remotely.

Incidentally, the tool I’m using (under OS X) for shader work is GLSLEditorSample, which is included with the (free) developer tools (/Developer/Examples/OpenGL/Cocoa/GLSLEditorSample). It’s… not quite as sucky as the only other option. I hear there are tools for Windows which are actually usable.

User avatar
Selezen
---- E L I T E ----
---- E L I T E ----
Posts: 2512
Joined: Tue Mar 29, 2005 9:14 am
Location: Tionisla
Contact:

Post by Selezen »

I think I'll just give up this modelling lark.

Seriously, that Krait is awesome.

I'll take solace in the fact that I was trying not to distort or mangle the classic models too much, and was trying to keep the poly count low enough not to melt computers.

<sobs quietly in the corner>

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 »

Selezen wrote:I think I'll just give up this modelling lark.

Seriously, that Krait is awesome.

I'll take solace in the fact that I was trying not to distort or mangle the classic models too much, and was trying to keep the poly count low enough not to melt computers.

<sobs quietly in the corner>
Pick yourself up, man, your works are excellent :D
Seriously, I cannot wait until you publish the new and improved Imperial Courier for public consumption. And I mean that, I have a save-file with the Mk I waiting for the update.

Captain Hesperus
"Fanatical? You should see his trophy rack and armoury before you make accusations...."

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2298
Joined: Fri Jul 14, 2006 12:29 pm
Location: Wales

Post by Griff »

no way should you give up the oxp-ing selezen, i mean the stuff you're doing over in the dream team thread is total quality, you seem to have a knack for updating the ships whilst keeping all their 'eliteness' qualities, i mean look at my krait, you have to squint your eyes really tightly until it begins to resemble the classic ship, in fact, you probably need to shut your eyes completely for it to start looking anything like the original :)

Was it Charlie who mentioned how dificult it is to update the ships back when he started work on what became the shady cobra? i totally agree, it's impossible, which is why i decided as an exercise not to bother following the original shape to much for the krait, just keep it vaguely arrow shaped with two guns on the side! so really, i've had a totally unfair advantage over you, plus i have a lot of spare time to tinker about in lightwave & photoshop and like you mention, i didn't give two figs about the polycount!

Ahruman,
oops, i meant seeing the intense glow when the ships used their injectors brought me close to tears of happiness not sadness! It's a really cool effect, i can imagine it being used on ships to give the impression that they are now 'angry' with you for taking a few pot-shots at them.
regarding the blueness in the shady ships, if no-one else has reported it then i wonder if it's something wrong with my pc? I'm playing the windows version of oolite on a windows XP PC with an ATI 9500pro graphics card - with fairly newish drivers and it's entirely possible there's some problem with my setup, hopefully some other windows players can let us know if appearing ok for them.


here's two screenshots from the start screen, it's just the shady ships that are appearing blue, the unshaded ones are appearing ok.
Image
Image
you can see the specularity is working ok, as seen on the wing of the krait, it's not a good screenshot but surfaces pointed towards the 'sunlight' get whiter, it's just that the rest of the model seems to be bathed in a blue ambient light (or there's maybe something in the vertex or fragment shader that is adding a lot of blue to the result)
i mentioned that ingame the colour of the ship varied from blue to purple depending on it's orientation, prehaps this is just the effect of the colour of the systems sun being added to the blue tinted ship, does this give a clue that maybe the blue is being added to the texture before the effect of the system sun on the surface is being calculated?

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 »

Griff wrote:oops, i meant seeing the intense glow when the ships used their injectors brought me close to tears of happiness not sadness!
Yes, I got that. :-) What I meant is: when a ship goes to afterburners, its engine_level in the shader goes above 1.0, making the glow effect oversaturated. The Shady Cobra’s shader clamps it, as does the engine glow on the krait, but the body glow doesn’t. In the case of the blue krait, it looks good; with the red one, it turns a bit weird.

It's a really cool effect, i can imagine it being used on ships to give the impression that they are now 'angry' with you for taking a few pot-shots at them.
regarding the blueness in the shady ships, if no-one else has reported it then i wonder if it's something wrong with my pc? I'm playing the windows version of oolite on a windows XP PC with an ATI 9500pro graphics card - with fairly newish drivers and it's entirely possible there's some problem with my setup, hopefully some other windows players can let us know if appearing ok for them.
Griff wrote:here's two screenshots from the start screen, … it's just that the rest of the model seems to be bathed in a blue ambient light (or there's maybe something in the vertex or fragment shader that is adding a lot of blue to the result)
Hmm… please try these four fragment shaders:

Code: Select all

void main(void)
{
    gl_FragColor = gl_FrontMaterial.ambient;
}

Code: Select all

void main(void)
{
    gl_FragColor = gl_LightModel.ambient;
}

Code: Select all

void main(void)
{
    gl_FragColor = gl_LightSource[0].ambient;
}

Code: Select all

void main(void)
{
    gl_FragColor = gl_LightSource[1].ambient;
}

User avatar
Charlie
---- E L I T E ----
---- E L I T E ----
Posts: 262
Joined: Wed Sep 27, 2006 5:33 pm

Post by Charlie »

HMOG! :shock: :D ... 8)
Benulobiweed.inc
By Appointment to
--- : GalCoop : ---

Your nearest Benulobiweed.inc dealer:
http://www.box.net/public/b2tic3tjsk#main

Charlie

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2298
Joined: Fri Jul 14, 2006 12:29 pm
Location: Wales

Post by Griff »

Ahruman, sorry to be a pain, what do i do with that shader code? do i copy the four examples into each of the .fragment file in the kraits Shaders folder?

Charlie, you've got to get hold of the 1.68 version of Oolite and get stuck into the glowy stuff, it looks unbelievable... specular highlights on hulls, engine exhausts all glowing hot, you see heat spreading across the hull from the gun mountings..drool..gibber...basically, it's totally up your psychedelic mind-blowing alley!

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 »

Griff wrote:Ahruman, sorry to be a pain, what do i do with that shader code? do i copy the four examples into each of the .fragment file in the kraits Shaders folder?
The easiest way would be to copy one into ahruman-griff-krait-skin-3&4.fragment (replacing everything there, make backup yadda yadda), launch Oolite, press N, press left arrow to see the thing on the demo screen. Taking out other OXPs should make this speedy enough.

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2298
Joined: Fri Jul 14, 2006 12:29 pm
Location: Wales

Post by Griff »

i was pasting the code into the shader so it ended up looking like this:-

Code: Select all

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

uniform float			time;
uniform float			engine_level;
uniform float			hull_heat_level;


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


// Colour ramp from black through reddish brown/dark orange to yellow-white.
vec4 TemperatureGlow(float level)
{
	vec4 result;
	
	result.r = level;
	result.g = level * level * level;
	result.b = max(level - 0.7, 0.0) * 2.0;
	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 * 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;
}


// 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_LightSource[idx].ambient; \
		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), 40.0); \
	}


void main(void) 
{ 
    gl_FragColor = gl_LightSource[0].ambient; 
}

the 1st one made the top part of the hull bright white
the 2nd and 3rd ones made the top part of the hull dull grey
the 4th one made the top part of the hull black


i'd also tried saving out each one of those examples into a .fragment file, then placing these in the oxp's Shaders folder then editing
the shipdata.plist shaders entry to add them into the fragment_shader array as below but that didn't do anything, the ship still stayed blue

Code: Select all

		<key>shaders</key>
		<dict>
			<key>griff_krait_skin_1&2.png</key>
			<dict>
				<key>textures</key>
				<array>
					<string>griff_krait_shaded_skin_1&2.png</string>
				</array>
				<key>vertex_shader</key>
				<string>ahruman-generic.vertex</string>
				<key>fragment_shader</key>
				<string>ahruman-griff-krait-basic.fragment</string>
				<string>FrontMaterial.fragment</string>
				<string>LightModel.fragment</string>
				<string>LightSource0.fragment</string>
				<string>LightSource1.fragment</string>
			</dict>
		</dict>
	</dict>

Post Reply