Shaders’ Outpost

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

Moderators: winston, another_commander

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

Re: Shaders’ Outpost

Post by Griff »

Hi no, that won't work, you can't specify shaders in 'materials =' they have to go inside 'shaders =', something like this:-
edit: sorry, that was bad advice - see Ahruman's post below

Code: Select all

shaders = 
	{ 
		"accipiter_no_shaders.png" = 
		{ 
			vertex_shader = "ahruman-generic-accipiter.vertex"; 
			fragment_shader = "accipiter-effects.fragment"; 
			textures = 
					(
						"accipiter_diffuse.png", 
						"accipiter_lights.png",
						"accipiter_effects.png"
					);
			uniforms =
					{
					tex0 = { type = texture; value = 0; };
					tex1 = { type = texture; value = 1; };
					tex2 = { type = texture; value = 2; };
					time = "universalTime";
					engine_level = "speedFactor"; 
					hull_heat_level = "hullHeatLevel";
					laser_heat_level = "laserHeatLevel";
					}; 	
		}; 
	};
although the rocket shader oxp is really old now and will need a re-write to work with the current Oolite so it's not worth bothering with it now and just using materials which have really come on in leaps and bounds since the rocket oxp was made, you can get nearly all the effects from the rocket shader oxp just using them (exceptions are the engine glow and laser gun heat glow effects - both generated using the effects_map texture, so if you leave the effects_map line out of your materials code you posted you should be set, you might also want to add in your materials some specularity settings eg:-

Code: Select all

specular_color = ( 0.2, 0.2, 0.2 );  // Applies when specular map is not used (no shaders) 
shininess = 5;
Last edited by Griff on Fri May 06, 2011 7:30 am, edited 1 time in total.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Shaders’ Outpost

Post by JensAyton »

Griff wrote:
Hi no, that won't work, you can't specify shaders in 'materials =' they have to go inside 'shaders =', something like this:-
Griff, you really should read the fine manual some time. :-)

It is necessary to set up the textures the way Griff demonstrated if you’re using custom shaders, though.
User avatar
Staer9
---- E L I T E ----
---- E L I T E ----
Posts: 570
Joined: Fri Feb 18, 2011 4:53 pm
Location: Hatfield, Hertfordshire (poor industrial)

Re: Shaders’ Outpost

Post by Staer9 »

Thanks Griff and Ahruman,

although the rocket shader seems to work fine on my game.
Image
User avatar
ace\56
Above Average
Above Average
Posts: 19
Joined: Tue Oct 11, 2011 12:14 pm

Re: Shaders’ Outpost

Post by ace\56 »

I need a shader with diffuse, ilumination, specular and normal map support (can be spec baked to diffuse and illumination baked to normal)
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Shaders’ Outpost

Post by Svengali »

You could simply use the materials entries. All of the requested functionality is supported there.

Or should this shader do something special?
User avatar
MiMoriarty
Competent
Competent
Posts: 39
Joined: Mon Nov 14, 2011 1:03 pm
Location: Madrid, España
Contact:

Re: Shaders’ Outpost

Post by MiMoriarty »

Hi, I'm trying to add some engine heat effect through shaders to my ships. I have been following Griff and Ahruman's examples but I'm unable to understand how they work and i've failed. Should 3D models be normal mapped for the shaders to work? I thought they don't but now I've doubts about that.

Programing fragment vertex its beyond my possibilities because i'm not programer. I believed i will be able to tweak the examples' shaders but i've failed by now. Is there any DON'T PANIC, shaders for dummies, tutorial you can spare with me, please?
There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. … Clearly, it is this second part, the missing, which presents the difficulties.
Blog http://mimoriarty.wordpress.com/
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

Re: Shaders’ Outpost

Post by Griff »

Hi MiMoriarty
You don't need to have the model normalmapped for shaders to work - I think the problem here is that that rocket shader example is so old that it no longer works in the way that Oolite expects it to, the main problem being that nowadays Oolite needs a list of all your textures written out as 'Uniforms' in the shipdata.plist, when the rocket shader was written you didn't need to do this as Oolite automatically assigned the uniform names Tex0, Tex1 etc to your textures and the shader is written to use these names.
I can have a go at updating the rocket shader example to work again this weekend and i'll try and write out a guide that explains how i'm doing this engine heat effect in the shaders in my shipset, it's not a very complex effect, just a matter of mixing some extra glowmaps onto the ship
User avatar
MiMoriarty
Competent
Competent
Posts: 39
Joined: Mon Nov 14, 2011 1:03 pm
Location: Madrid, España
Contact:

Re: Shaders’ Outpost

Post by MiMoriarty »

I can have a go at updating the rocket shader example to work again this weekend and i'll try and write out a guide that explains how i'm doing this engine heat effect in the shaders in my shipset, it's not a very complex effect, just a matter of mixing some extra glowmaps onto the ship
Griff. That would be very nice from you. :o
There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. … Clearly, it is this second part, the missing, which presents the difficulties.
Blog http://mimoriarty.wordpress.com/
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

Re: Shaders’ Outpost

Post by Griff »

Seems to be a bit quiet at work so i had a quick look at the oxp, well, what a balst from the past! i grabbed the "Griff Rocket Shader Test - Engine Level Lights.zip file" from http://www.box.com/shared/h95rd0n25x (listed as Griff Rocket Example 2 in the first post of this thread), if you change the shipdata.plist to this

Code: Select all

{
// ++++++           Griff Rocket Example               ++++++
"griff_rocket" = 
	{
	like_ship = "cobra3-trader";
	exhaust = ("0 0 -49.0 10.0 10.0 25.0");
	model = "griff_rocket.dat"; 
	name = "Griff Rocket";	
	roles = "griff_rocket";
	smooth = true;	
	shaders = 
		{ 
            "griff_rocket_unshaded_diffuse.png" = 
			{ 
                vertex_shader = "ahruman-generic.vertex"; 
                fragment_shader = "griff_rocket.fragment"; 
                textures = 
						(
							"griff_rocket_shaded_diffuse.png", 
							"griff_rocket_enginelevel_glowmap.png",
							"griff_rocket_effects.png"
						);
				uniforms =
						{
						tex0 = { type = texture; value = 0; };
						tex1 = { type = texture; value = 1; };
						tex2 = { type = texture; value = 2; };	
						time = "universalTime";
						engine_level = "speedFactor";	
						hull_heat_level = "hullHeatLevel";
						laser_heat_level = "laserHeatLevel";					
						}; 	
			}; 
		};
	};	
}
(Sorry, i had to change it from XML to Openstep format - i could't remember how to do the XML code)
and also change the script.js file in the Config folder to this:

Code: Select all

// Configuration -- customize here 
this.role = "griff_rocket"; 
this.count = 3; 

// Standard attributes 
this.name           = "Spawn-" + this.role; 
this.author         = "Jens Ayton"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0.1"; 
this.description    = "Script to make several ships of a given role appear at the witchpoint after every jump." 


this.shipWillLaunchFromStation = function() 
{ 
    system.legacy_addSystemShips(this.role, this.count, 1.0); 
    log("testscript.spawn", "Generated " + this.count + " " + this.role + " for testing purposes."); 
} 
it should get the oxp working again, although it still used the macro lighting code that we shouldn't be using!
When you launch the ammended script.js will spawn 3 rocket example ships near the station.
The next step i think will be to change the fragment shader to the normal map one that uses the Function to calculate lighting and re-post the oxp

How do you want to do the engine glows for your ship MiMoriarty, the current method is to just use the red and blue channels in a texture map recolour them orange and cyan in the shader and mix them into the texture - you don't have to do it this way - a simpler method would just be to paint out your final engine glow as a standard texture and add this onto the ship without having to mess around with single colour channels etc
here's a post where i seem to be trying to explain the single channel effects texture painting method
https://bb.oolite.space/viewtopic.ph ... &start=285
User avatar
MiMoriarty
Competent
Competent
Posts: 39
Joined: Mon Nov 14, 2011 1:03 pm
Location: Madrid, España
Contact:

Re: Shaders’ Outpost

Post by MiMoriarty »

Seems to be a bit quiet at work so i had a quick look at the oxp, well, what a balst from the past! i grabbed the "Griff Rocket Shader Test - Engine Level Lights.zip file" from http://www.box.com/shared/h95rd0n25x (listed as Griff Rocket Example 2 in the first post of this thread), if you change the shipdata.plist to this
Code:
{
// ++++++ Griff Rocket Example ++++++
"griff_rocket" =
{
like_ship = "cobra3-trader";
exhaust = ("0 0 -49.0 10.0 10.0 25.0");
model = "griff_rocket.dat";
name = "Griff Rocket";
roles = "griff_rocket";
smooth = true;
shaders =
{
"griff_rocket_unshaded_diffuse.png" =
{
vertex_shader = "ahruman-generic.vertex";
fragment_shader = "griff_rocket.fragment";
textures =
(
"griff_rocket_shaded_diffuse.png",
"griff_rocket_enginelevel_glowmap.png",
"griff_rocket_effects.png"
);
uniforms =
{
tex0 = { type = texture; value = 0; };
tex1 = { type = texture; value = 1; };
tex2 = { type = texture; value = 2; };
time = "universalTime";
engine_level = "speedFactor";
hull_heat_level = "hullHeatLevel";
laser_heat_level = "laserHeatLevel";
};
};
};
};
}

(Sorry, i had to change it from XML to Openstep format - i could't remember how to do the XML code)
and also change the script.js file in the Config folder to this:
Code:
// Configuration -- customize here
this.role = "griff_rocket";
this.count = 3;

// Standard attributes
this.name = "Spawn-" + this.role;
this.author = "Jens Ayton";
this.copyright = "This script is hereby placed in the public domain.";
this.version = "1.0.1";
this.description = "Script to make several ships of a given role appear at the witchpoint after every jump."


this.shipWillLaunchFromStation = function()
{
system.legacy_addSystemShips(this.role, this.count, 1.0);
log("testscript.spawn", "Generated " + this.count + " " + this.role + " for testing purposes.");
}

it should get the oxp working again, although it still used the macro lighting code that we shouldn't be using!
When you launch the ammended script.js will spawn 3 rocket example ships near the station.
The next step i think will be to change the fragment shader to the normal map one that uses the Function to calculate lighting and re-post the oxp

How do you want to do the engine glows for your ship MiMoriarty, the current method is to just use the red and blue channels in a texture map recolour them orange and cyan in the shader and mix them into the texture - you don't have to do it this way - a simpler method would just be to paint out your final engine glow as a standard texture and add this onto the ship without having to mess around with single colour channels etc
here's a post where i seem to be trying to explain the single channel effects texture painting method
viewtopic.php?f=4&t=3460&start=285
Many thanks, Griff. I'm in the office too and some kind of busy now. I'll give it a try this evening.
There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. … Clearly, it is this second part, the missing, which presents the difficulties.
Blog http://mimoriarty.wordpress.com/
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Shaders’ Outpost

Post by JensAyton »

I’ve made a simplified version of the Griff Adder shader. It does everything the original does except decals, but with less and better-organized code, and lots of comments. It also does away with obsolete stuff like trying to deal with two light sources.

It doesn’t include the model or textures, so the Griff Adder or all-in-one OXP must be installed for it to be usable in-game.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Shaders’ Outpost

Post by Thargoid »

The shaders in Vortex OXP does simply the engine glow and a heat effect on the whole ship. It may be a simpler example than Griffs, as I stripped things right back to only those two items.

The colormap there is the texture (the diffuse map used by the main model) and the emission map is basically just the engine glow.
User avatar
MiMoriarty
Competent
Competent
Posts: 39
Joined: Mon Nov 14, 2011 1:03 pm
Location: Madrid, España
Contact:

Re: Shaders’ Outpost

Post by MiMoriarty »

Many Thankx, Ahruman, Thargoid and Griff.

I took the vortex.oxp's shaders and they worked pretty well in the engines of my OXP. Now that it works i'd start learning how IT really WORKS using Ahruman and Griff's code and try to make it on my own shaders for other effect.
There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. … Clearly, it is this second part, the missing, which presents the difficulties.
Blog http://mimoriarty.wordpress.com/
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

Re: Shaders’ Outpost

Post by Griff »

MiMoriarty wrote:
...Now that it works i'd start learning how IT really WORKS using Ahruman and Griff's code and try to make it on my own shaders for other effect.
It's best to use Ahruman's shaders to study as all the ones in my shipsets are just badly cobbled together versions of his originals. :D
The Adder shader Ahruman posted a few posts up is stuffed full of comments explaining what's going on in the code.
Shader .vertex and .fragment files can be opened and edited in a text editor program, some sort of shader development program can really help too - they're really handy for previewing your work without having to launch Oolite and finding your ship - if you're on a Windows PC, AMD have a really cool free program called Rendermonkey and i think there's something available for free from Apple if you're on a Mac (might be part of some sort of development suite of programs)
User avatar
MiMoriarty
Competent
Competent
Posts: 39
Joined: Mon Nov 14, 2011 1:03 pm
Location: Madrid, España
Contact:

Re: Shaders’ Outpost

Post by MiMoriarty »

if you're on a Windows PC, AMD have a really cool free program called Rendermonkey and i think there's something available for free from Apple if you're on a Mac (might be part of some sort of development suite of programs)
No, I don`t :lol: . I will try with XCODE's OpenGL Shader Builder. It's the only one i've found.
There is an art, it says, or rather, a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. … Clearly, it is this second part, the missing, which presents the difficulties.
Blog http://mimoriarty.wordpress.com/
Post Reply