Page 10 of 15

Posted: Tue Mar 02, 2010 3:07 pm
by Diziet Sma
If -nosplash doesn't work, then it's likely that you will need a driver update to fix it.

Posted: Tue Mar 02, 2010 3:42 pm
by Scarecrow
No idea what -nosplash is but it works perfectly - didn't realise using two monitors would cause a problem.
Should've searched the boards first :D Thanks, both.

Right. Shaders. sigh. I'll be back later, probably with a LOT of questions.

Crow

Posted: Tue Mar 02, 2010 3:54 pm
by Scarecrow
Okay then,

Just in case my tiny, butterfly mind flitters off again before I actually finish this, for those of you interested, you can get the Seraphim OXP as it stands from here:

Seraphim Police Viper replacement OXP

It consists of only a diffuse texture for now. If and when I get all the fancy normal maps and shaders on it, I'll update it and post here.

For now, enjoy.

Crow

Posted: Tue Mar 02, 2010 4:24 pm
by Scarecrow
Okay, let's start at the beginning.

I'm looking at Griff's rocket example. The first section in the Fragment file is this:

Code: Select all

// Information from Oolite.
uniform sampler2D      tex0; // Difuse map
uniform sampler2D      tex1; // Glow map (always on)
uniform sampler2D      tex2; // effects map
It appears to be assigning the various textures to variable slots, but I couldn't figure out how. How does it know, for example that tex0 is the Diffuse map? I noticed that the line at the top says, 'information from oolite' so I guessed that maybe the textures are set up in the ship's config file.

I jumped over to the Rocket's Plist and sure enough, there's a shader setup:

Code: Select all

	<key>shaders</key>
		<dict>
			<key>griff_rocket_unshaded_diffuse.png</key>
			<dict>
				<key>textures</key>
					<array>
					<string>griff_rocket_shaded_diffuse.png</string>
					<string>griff_rocket_permaglowmap.png</string>
					<string>griff_rocket_effects.png</string>
					</array>
				<key>vertex_shader</key>
				<string>ahruman-generic.vertex</string>
				<key>fragment_shader</key>
				<string>griff_rocket.fragment</string>
			</dict>
		</dict>	
	</dict>
It does appear to be listing the three textures used in the shader and in the order that they are listed in the Fragment file. I assume that this is true: That if the diffuse texture is listed first then it will automatically become tex0 in the Fragment file?

Also, what's this line for:

Code: Select all

<key>griff_rocket_unshaded_diffuse.png</key>
It refers to the texture that has 'Shader Disabled' written all over it. I assume that this is the default texture that will be used if the shader fails to run correctly?

The other big stumbling block is that this code is in HTML and I've no idea what this code should look like in script which is what the rest of my Plist is written in.

Comments? Answers? yes? no? :)

Crow

Posted: Tue Mar 02, 2010 4:34 pm
by DaddyHoggy
Scarecrow wrote:
Okay, let's start at the beginning.

I'm looking at Griff's rocket example. The first section in the Fragment file is this:

Code: Select all

// Information from Oolite.
uniform sampler2D      tex0; // Difuse map
uniform sampler2D      tex1; // Glow map (always on)
uniform sampler2D      tex2; // effects map
It appears to be assigning the various textures to variable slots, but I couldn't figure out how. How does it know, for example that tex0 is the Diffuse map? I noticed that the line at the top says, 'information from oolite' so I guessed that maybe the textures are set up in the ship's config file.

I jumped over to the Rocket's Plist and sure enough, there's a shader setup:

Code: Select all

	<key>shaders</key>
		<dict>
			<key>griff_rocket_unshaded_diffuse.png</key>
			<dict>
				<key>textures</key>
					<array>
					<string>griff_rocket_shaded_diffuse.png</string>
					<string>griff_rocket_permaglowmap.png</string>
					<string>griff_rocket_effects.png</string>
					</array>
				<key>vertex_shader</key>
				<string>ahruman-generic.vertex</string>
				<key>fragment_shader</key>
				<string>griff_rocket.fragment</string>
			</dict>
		</dict>	
	</dict>
It does appear to be listing the three textures used in the shader and in the order that they are listed in the Fragment file. I assume that this is true: That if the diffuse texture is listed first then it will automatically become tex0 in the Fragment file?

The other big stumbling block is that this code is in HTML and I've no idea what this code should look like in script which is what the rest of my Plist is written in.

Comments? Answers? yes? no? :)

Crow
The original files (eg. Ahruman's examples from which I think Griff based most of his original work) were in XML as you have indicated - the newer codes are in OpenStep - I think somebody has written a converter to go from one to the other - I think it was done for Lestradae when he was porting OXPs across to O(S)E.

Posted: Tue Mar 02, 2010 4:48 pm
by Scarecrow
Ah! I've found an OpenStep version in Griff's Boa oxp.

Okay, so it appears that I need to set up shaders for each and every sub object too.
As I'll be using the same textures for all parts of the ship, is it possible to set the shader up just once in the Shipdata.Plist file and if so, where would I put it?

Crow

Posted: Tue Mar 02, 2010 4:51 pm
by Scarecrow
Okay, I think I've started ahead of myself.

I'm going to forget the .vertex and .fragment files for now. I think I need to learn how to set the shaders up in the shipdata.plist first.

First I shall read this page in the Wiki

Crow

Posted: Tue Mar 02, 2010 5:11 pm
by Griff
Scarecrow wrote:
Okay, so it appears that I need to set up shaders for each and every sub object too.
As I'll be using the same textures for all parts of the ship, is it possible to set the shader up just once in the Shipdata.Plist file and if so, where would I put it?
I think this is possible, you'd write out one subentity object in the shipdata.plist with all its shader definitions, then for all the other subentites you'd just like_ship = "the original subentity"; them all and they will inherity the original subentitys stats and shader settings without you having to write them all out.
Have a look at this page too: http://wiki.alioth.net/index.php/Materials_in_Oolite you can use materials to provide texture for Oolites built in shaders, then you don't have to worry about creating vertex & fragment shaders, your ship will use the built in oolite ones.
I'm not sure which oxp's use materials so i can't link you to any examples at the moment, hopefully somebody will pass by with some links

Posted: Tue Mar 02, 2010 5:14 pm
by Scarecrow
Okay, then...

Looking at the shader setup in the griff_boa, I see this:

Code: Select all

shaders = 
		{ 
            "griff_boa_mainhull.png" = 
			{ 
                vertex_shader = "ahruman-generic.vertex"; 
                fragment_shader = "Griff_Boa_Mainhull_g_channel_decals.fragment"; 
             
                textures = ("griff_boa_mainhull.png", "griff_boa_engines_effects.png", "griff_boa_engines_diffuse.png", {name = "griff_decals_set1.png"; repeat_s = "yes";});
			
				uniforms = 
				{ 
				uTime = "universalTime";
				nearly_dead = "throwingSparks";	
				hull_heat_level = "hullHeatLevel";	 				
				engine_power = "speedFactor"; 
				blinkrate = { type = "float"; value = 0.8; };
				PaintColor = { type = vector; value = "0.0 0.0 0.0"; };
				DecalColor = { type = vector; value = "1.0 0.9794 0.4736"; };
				uDecalSelect = { type = "float"; value = 0.95; };
				}; 			
			}; 
		}; 
The second line, "griff_boa_mainhull.png" looks like it's establishing a default texture for the shader. Then, going on the information in the wiki, I understand that line 3 and 4 are telling it which vertex shader to use and which Fragment shader to use. This has been confusing me for a while as we call them Pixel shaders.
Next the fifth line is telling it which textures to use. I'm still assuming that these will be assigned tex0, tex1 and tex2 in the Fragment shader dependent on the order that they are listed here.
Finally, Uniforms appear to be entirely optional, will default if not specified here and not something I need to worry about right now.

Unless I'm totally off mark, Cool.

Crow

Posted: Tue Mar 02, 2010 5:19 pm
by Scarecrow
Griff wrote:
Have a look at this page too: http://wiki.alioth.net/index.php/Materials_in_Oolite you can use materials to provide texture for Oolites built in shaders, then you don't have to worry about creating vertex & fragment shaders, your ship will use the built in oolite ones.
I'm not sure which oxp's use materials so i can't link you to any examples at the moment, hopefully somebody will pass by with some links
Oh. Actually that looks much more like the sort of thing I'm after. I might try playing with that first. I'd definately like to learn to use shaders properly though. We use them a lot in work and it's something I need to really understand properly.

Also, is 'Like_Ship' an actual command or are you just using a stand-in?

Cheers, Griff.

Crow

Posted: Tue Mar 02, 2010 5:34 pm
by Eric Walch
Scarecrow wrote:
I'm used to Material editors in 3D programs that give me slots. All I need to do is tell it which diffuse texture to use, which normal map texture to use, which specular texture (or value) to use. Sadly, it doesn't seem that simple in Oolite
....
Finally, Uniforms appear to be entirely optional, will default if not specified here and not something I need to worry about right now.
I have never used the shader directory, but I think uniforms are essential. The uniforms are the things that make the texture dynamical based on ship properties. (e.g. engine glow, based on the ships speed) When you just want static textures, you can just as well use the materials directory. See wiki-materials.
See for instance the latest asteroids.oxp were specular and normal maps are only added by the material directory.

Posted: Tue Mar 02, 2010 5:54 pm
by Scarecrow
Eric Walch wrote:
See for instance the latest asteroids.oxp were specular and normal maps are only added by the material directory.
Cool. Can you link me, a search threw up nothing obvious.

Crow

Posted: Tue Mar 02, 2010 6:14 pm
by Eric Walch
Scarecrow wrote:
Cool. Can you link me, a search threw up nothing obvious.
I used the wrong name. I mend asteroid storm.oxp not asteroids

Posted: Tue Mar 02, 2010 8:15 pm
by JensAyton
Scarecrow wrote:
It does appear to be listing the three textures used in the shader and in the order that they are listed in the Fragment file. I assume that this is true: That if the diffuse texture is listed first then it will automatically become tex0 in the Fragment file?
This is correct: tex0, tex1 etc. correspond to the ordering in the textures array.

The recommended approach, though, is to use descriptive uniform names and bind them using the uniforms dictionary:

Code: Select all

uniforms =
{
    uDiffuseMap = { type = texture; value = 0; };
    uPermaGlowMap = { type = texture; value = 1; };
    uRocketEffectsMap = { type = texture; value = 2; };
};
Scarecrow wrote:
Also, what's this line for:

Code: Select all

<key>griff_rocket_unshaded_diffuse.png</key>
This is the material key, which is used to distinguish between multiple materials in the DAT file. Usually this is the name of a texture, but it doesn’t have to be. If there is no shaders or materials entry for a given material key, it’s treated as a diffuse map texture name (as explained in Materials in Oolite).

For example, when the Griff Rocket is loaded and shaders are disabled or not available, Oolite will look for a materials dictionary (instead of shaders), but not find it, and fall back to the default behaviour. This is equivalent to having a materials dictionary that looks like this:

Code: Select all

materials =
{
    "griff_rocket_unshaded_diffuse.png" =
    {
        diffuse_map = "griff_rocket_unshaded_diffuse.png";
    };
};

Posted: Tue Mar 02, 2010 8:28 pm
by Griff
Scarecrow wrote:
Also, is 'Like_Ship' an actual command or are you just using a stand-in?
yep, it's a shipdata.plist command
http://wiki.alioth.net/index.php/Shipda ... #like_ship

here's an example from the shipdata.plist that comes with Oolite

Code: Select all

	"wreckage-component" =
	{
		ai_type = "nullAI.plist";
		cargo_type = "CARGO_NOT_CARGO";
		energy_recharge_rate = 0;
		forward_weapon_type = "WEAPON_NONE";
		fragment_chance = 0.2;
		max_energy = 2000;
		max_flight_pitch = 2;
		max_flight_roll = 2;
		max_flight_speed = 500;
		model = "wreck1.dat";
		name = "Wreckage";
		roles = "wreckage oolite-wreckage-component";
		scanClass = "CLASS_CARGO";
		thrust = 0;
	};
	"more-wreckage2" =
	{
		like_ship = "wreckage-component";
		model = "wreck2.dat";
		roles = "wreckage oolite-more-wreckage2";
	};
'more-wreckage2' will inherit all the stats of the "wreckage-component" ship it is 'like_shipped' too, this will include materials and shader definitions, from what i remember you have to always specify a role and a model otherwise oolite will reject the ship* (the role could be something like 'scarecrow-seraphim-subentity' and used for all the subentities in the ship)

*unless it's setup as a ship 'template' using the 'is_template' command. Template ships won't appear in game though, they are literally just a template ship for other ships to refer to inorder to cut down on a lot of duplicate info in the shipdata.plist