The Seraphim - A custom Ship OXP from start to finish.

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

Moderators: winston, another_commander

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:
iit looks like the alpha channel is being used for the specular exponent (the highlight size or the 'glossyness' of the surface), i'm just wondering if it might be better to make it control specular intensity instead, or change the 'shininess' name to 'glossyness' or something like that? shininess sounds more like a specular intensity setting i think ? <- i'll put a question mark there because i'm not entirely sure myself!
“Shininess” for specular exponent is a semi-standard usage – for instance, it’s used in OpenGL’s default lighting model. It makes sense in physical terms: a high exponent, with any intensity level, corresponds to a glossy surface; a low exponent with a low intensity level corresponds to a matte surface; a low exponent with a high intensity is nonsense. In any case, if the specular map is opaque the explicit shininess value of 64 will be used everywhere without scaling.
Scarecrow wrote:
PNG's don't have an alpha channel as such. They just sort of remember when something is transparent.
This is entirely wrong (and doesn’t actually make any sense). PNGs have an alpha channel, but some tools (*coughphotoshopcough*) don’t have the option to import it as a separate channel.
Scarecrow wrote:
Is it concievable that this is a bug with Oolite's material code that hasn't been spotted before?
Possibly, could you send me the OXP for testing?

(Random nit-pick: “seraphim” is plural. The singular is “seraph”.)
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Ahruman wrote:
Scarecrow wrote:
PNG's don't have an alpha channel as such. They just sort of remember when something is transparent.
This is entirely wrong (and doesn’t actually make any sense). PNGs have an alpha channel, but some tools (*coughphotoshopcough*) don’t have the option to import it as a separate channel.
Well, allright, :P Obviously it has an alpha channel, what I meant was, the program I'm using (*coughphotoshopcough*) doesn't allow me to save it with an alpha channel. It uses the tranparency in the RGB channels instead.
Ahruman wrote:
(Random nit-pick: “seraphim” is plural. The singular is “seraph”.)
Ah well, I prefer Seraphim :D

Anyway, at the moment it seems that colour information in the specular map is being ignored and the opacity of the alpha channel is simply masking out the shininess and specular values.

I'll send you the OXP asap so you can take a look.

Something else that occured to me is that, excluding the specular map, and even with the shininess and specular up full, it's still not that shiny. I'd expect those faces, when the normals are facing the light to be totally bleached out.

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
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 »

Scarecrow wrote:
Well, allright, :P Obviously it has an alpha channel, what I meant was, the program I'm using (*coughphotoshopcough*) doesn't allow me to save it with an alpha channel. It uses the tranparency in the RGB channels instead.
Odd; in my experience it will save separate alpha channels but not load them that way.
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Nah. I'm using CS2 and it complains when I try to save with an alpha channel, telling me I need to save it as a copy. When I open it again, there's nothing there. If I merge layers, retaining opacity - even anti-aliased opacity - it 'remembers' it. Almost as if rather than being on a seperate channel, it's baked into the rgb channels.

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
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 »

Scarecrow wrote:
Something else that occured to me is that, excluding the specular map, and even with the shininess and specular up full, it's still not that shiny. I'd expect those faces, when the normals are facing the light to be totally bleached out.
I had quite other experiences. When you run trunk Oolite you could look at: cargowreck showroom A small display oxp that also needs the latest cargoWreck.oxp. It shows the barrels in full size using some new 1.74 methods. Those barrels only use the specular map (with alpha channel). Some are almost to shiny.
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Right then,

This morning I ripped a chunk of code from Griff's Adder and dropped it in in place of my materials code, editing the texture names accordingly (and putting the corresponding .vertex and .fragment in the shaders folder.)

Result! The shininess and specular effect is much closer to what I expected to see with the specular and shininess up full in the materials setting.

It seems that shaders are the way forward, at least for now.

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Okay, I'm looking for an easy way into this. I'm an artist, not a programmer (dammit, Jim) and every which way I approach this, I'm confronted with indecipherable programming gibberish.

I think the easiest way for me to ease myself into shaders is to learn how to set up the data in the Shipdata.plist first.

Is there any reason I can't use the standard Oolite shaders for this to begin with?
If I can use the standard Oolite shaders, and as my ship is using a normal map, should I use the tangent space .vertex instead of the standard .vertex shader?

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2483
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

i think it's those default shaders that are used when you do the 'materials' stuff, infact i think they're used by everything in the game that doesn't have it's own shaders definitions in it's shipdata.plist, even when you have shaders switched to off *Neo from matrix 'woah!'* :D
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

sh1t. :(

So I need to write my own shaders before I can even begin?

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2483
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

don't despair, lets turn that frown upside down!

rather than writing your own shader, we could adapt any of the ones out there in readily available OXPs, *engage griff pimp mode* the ones in the griff normal map ships all come from Ahrumans examples, all been mucked about with by me and despite my best efforts to break them are still mostly bug free, maybe once you've got one doing what you want it'll be easier to pick it apart and base other custom shaders off it?

how would you like the shaders to work? the griff ones are usually something like this:
diffuse texture (spec intensity map in the alpha)
normal map (hull lights illumination map in the alpha, light colour is specified in a vec3 in the shader)
effects map - optional, red channel - orange engine glow, blue channel - cyan engine glow, green channel - laser gun heat glow, alpha channel - a greyscale paintmap, randomly recoloured and mixed into the final texture for the NPC ships
decal map - optional - series of decals stored in the RGBA channels, selected a coloured randomly and applied to the ship

we can easily change this, eg the spec intensity map could be in its own texture map instead of the alpha channel, the effects map could be a full colour light map rather than a greyscale image that's recoloured by the shader, the only limit is that i can't get the shaders to work with more that 4 texture maps, everything has to cram into that (hence using alpha channels a lot)
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:
i think it's those default shaders that are used when you do the 'materials' stuff, infact i think they're used by everything in the game that doesn't have it's own shaders definitions in it's shipdata.plist, even when you have shaders switched to off *Neo from matrix 'woah!'* :D
Not quite.
In full shader mode, they’re used for everything which doesn’t have custom shaders.
With shaders off, “fixed functionality” – rendering without shaders – is used for everything.
In simple shader mode, fixed functionality is used for non-smooth surfaces that don’t have any textures other than the diffuse map, and the default shaders are used otherwise.

You can use the default vertex shaders together with a custom fragment shader (the tangent space approach is recommended for new development), but the default fragment shader is designed to be controlled by a bunch of special macros that are set up by Oolite. In any case, using it directly wouldn’t give you any advantage over using the material model.
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Sigh. Thanks, Griff.

(WAIT! That's a smile, not an upside down frown!)

Okay, so what do I want the shader to do?

Well, I need to have a diffuse map, natch.

I'd like it to use the normal map for detail, a specular map for subtle light variations across the surface, an emission or light map for the lights in the cockpit and an effects map for the engine glow. I recall you were able to get it to switch on and off and even grow brighter dependent on thrust - am I right?

Also, is it possible to set up smoothing groups in the shaders as the model at the moment is totally faceted.

I'd ideally like to have an ambient occlusion pass aswell so that dark areas in the nooks and crannies stay dark but I don't know if that's possible in Oolite.

So that's five maps (not including the AO). Using the alpha channel makes sense and I can do that, though I might need to use GIMP because, as Ahruman pointed out, Photoshop has problems with the PNG alpha channel.

Where should I start? I guess I should look at Ahruman's examples and see how much I can decipher.

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
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 »

Scarecrow wrote:
Also, is it possible to set up smoothing groups in the shaders as the model at the moment is totally faceted.
Not as such. You could in principle bake an object-space normal map, if your tools support it; otherwise, it’s normal smooth groups or new-in-1.74 explicit vertex normals.
Scarecrow wrote:
I'd ideally like to have an ambient occlusion pass aswell so that dark areas in the nooks and crannies stay dark but I don't know if that's possible in Oolite.
Yes, it doesn’t require any special support in the game.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2483
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

ambient occlusion sounds interesting, from the shaders viewpoint is it a matter of multipling the total diffuse level for the fragment by a greyscale image? if so i might be able to add that to a shader. (disclaimer: only if it turns out to be really really easy though)
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:
ambient occlusion sounds interesting, from the shaders viewpoint is it a matter of multipling the total diffuse level for the fragment by a greyscale image? if so i might be able to add that to a shader. (disclaimer: only if it turns out to be really really easy though)
The usual, simple way of using AO is simply to multiply it with your diffuse colour. It’s so simple, in fact, that you can (and should) do it in advance in Photoshop/GIMP instead, unless you’re doing something more interesting with the map.

Like normal maps, AO maps can be generated from a high-poly model and applied to a lower-poly version.

SMAK looks like a decent AO tool for Windows. I believe NVidia and ATi both provide (free!) tools which handle AO baking as well as normal and parallax map baking, including mapping from high-poly models to low-poly ones.
Post Reply