Page 6 of 13

Re: Skinner’s Den

Posted: Fri Aug 19, 2011 9:08 am
by Big Bene
Big Daddy wrote:
If you look at the shady billboard oxp and shady thargoid oxps that Ahruman created you can see how "animated" textures work (Griff's done an amazing job on the YAH constores - so that would be another good example to see how the shader fragment works)
Ok, I'll have a look.
Big Daddy wrote:
I think you can switch textures inside an oxp for a ship using the materials setting
That's not what I intended in in my question. I wanted to know if I can use different pngs for different polygones of the same entity. But still, interesting information.
Pumpkinhead wrote:
You can't use more than one texture per ship
Now, that puts an answer to this.
evil Mantis from outer space wrote:
one texture per ship isn't completely always true - if the ship has sub-entities they will have their own individual textures distinct from the mother entity's
And this may be a solution...
Pumpkinhead wrote:

Code: Select all

"adder" =
   {
...
...
   };
Thanks, will give it a read-through.
evil Mantis from outer space wrote:
My Butterflies OXP might give you a taster both of physical animation
That's another topic, of course, but still very interesting!
evil Mantis from outer space wrote:
That can be used to simulate animation without shaders
So I assume true animation is possible with shaders?
evil Mantis from outer space wrote:
The other way for true animation is the already mentioned shader option (as championed by Griff and Ahruman) with several fine examples already mentioned.
Ah, yes.

So it all boils down to shaders for true animation.
But how to?
Guess I'll have to read through Griff's and Ahriman's OXPs. That's quite a reading...
:roll:

Thanks, guys. This really is the most helpful forum this side of Tionisla.

Re: Skinner’s Den

Posted: Fri Aug 19, 2011 11:49 am
by Killer Wolf
think you can have multiple textures for a ship, you just need to set it up in your modeller to assign the different polys to the different maps

Re: Skinner’s Den

Posted: Fri Aug 19, 2011 12:45 pm
by Eric Walch
Big Bene wrote:
...... I wanted to know if I can use different pngs for different polygones of the same entity. But still, interesting information.
Pumpkinhead wrote:
You can't use more than one texture per ship
Now, that puts an answer to this.
It is an answer, but not a correct one. When you look inside Oolite itself you will already find ships using more than one texture.
e.g. a simple object like the barrel uses both "barrel_metal.png" and "left_metal.png".

Re: Skinner’s Den

Posted: Fri Aug 19, 2011 1:33 pm
by Ironfist
Guys,
Just to confirm you can have more than 1 texture, here is a piece of the dat file of a ship I am currently working on.

cockpit_mat.png 1.0 1.0 0.93426 0.43684 0.93445 0.49746 0.96655 0.49746
cockpit_mat.png 1.0 1.0 0.93426 0.43684 0.96655 0.49746 0.96682 0.43684
draven_gunship_mat.png 1.0 1.0 0.66213 1.00000 0.69482 0.96509 0.65662 0.75167
draven_gunship_mat.png 1.0 1.0 0.66213 1.00000 0.65662 0.75167 0.64386 0.75167

The file names are directly from the material names in the wings3d file, although you could easily edit the dat file with a good text editor if you needed to.
This dat file was generated in the usual way exported in obj format then converted with Obj2DatTex.py.

Hope this helps
Ironfist

Re: Skinner’s Den

Posted: Fri Aug 19, 2011 2:33 pm
by Smivs
OK, so I was talking in simplistic terms.
You can apply more than one texture to a model if the various faces have different diffuse maps specified in the model (.dat) file, and as has been pointed out several core ships use this. The rock hermit actually uses several for example.
What I meant (again in simple terms) was that you cannot apply more than one 'skin' to a specific ship other than by creating a 'like_ship' and specifying the alternative texture in shipdata (although this can be changed 'on the hoof' using the materials attribute in js).
For example if you look in the Textures folder for the core ships you will see 2 different textures for the Cobra Mk3, called cobra3_redux.png and cobra3_redux1.png. These are used for different varieties of the Mk3, and only one of these skins can be applied to the model at any given time. What you can't do is take the same variety of Cobra3, say the 'trader', and sometimes apply one skin and other times apply the other skin.
The 'trader' gets cobra3_redux.png every time, because that is the diffuse_map specified in the model (.dat file). If you want to use the other skin, like the Cobra3-alternate does, then this has to be specified in the 'materials' section of shipdata, thus

Code: Select all

"cobra3-alternate" =
	{
		like_ship = "cobra3-trader";
		energy_recharge_rate = 3;
		has_ecm = 0.95;
		max_cargo = 35;
		max_energy = 250;
		max_flight_speed = 320;
		materials =
		{
			"cobra3_redux.png" = { diffuse_map = "cobra3_redux1.png"; };
		};
		roles = "hunter pirate trader hermit-ship sunskim-trader cobra3-alternate";
		thrust = 32;
		weapon_energy = 15;
	};
which the sharp-eyed amongst you will notice is essentially the same as the Adder example from my shipset I gave earlier.
So if you want three or four different types of any particular ship, you can't just somehow apply a 'random' texture from a list to it, you have to have each variety detailed in shipdata, and like_ship is the easiest way to do this.

Re: Skinner’s Den

Posted: Mon Sep 26, 2011 2:34 pm
by CaptSolo
I have a question for Griff or SimonB: How do you produce your effects maps? Most of the original diffuse texture is now green.

edit: hmmm okay, later that day the idiot (me) stumbles upon SimonB's excellent tutorial and saves a copy to his intelligent computing device (looking skyward mumbling). Now off to see if I can replicate somewhat similar results.

Re: Skinner’s Den

Posted: Tue Sep 27, 2011 2:17 am
by CaptSolo
Am I missing something or do I require better hardware? I have GIMP for Windows version 2.6.11 and do not seem to have a "mode" menu under "Layers". Trying to follow SimonB's tutorial on making an effects map from the diffuse texture. Got as far as duplicate layer, desaturate top layer etc., but could not proceed past the point where I am supposed to change the layer mode to "addition".

Re: Skinner’s Den

Posted: Tue Sep 27, 2011 8:08 am
by Smivs
Hi Solo,
This is in the layers dialogue box (Cont-L) not the layers drop-down from the main bar.

Image

Re: Skinner’s Den

Posted: Tue Sep 27, 2011 8:12 pm
by CaptSolo
Thanks Smivs. I never knew about this command. Opens a whole new world of possibilities.

Re: Skinner’s Den

Posted: Tue Sep 27, 2011 8:30 pm
by Smivs
CaptSolo wrote:
Thanks Smivs. I never knew about this command. Opens a whole new world of possibilities.
You wouldn't believe it. Enjoy! :)

Re: Skinner’s Den

Posted: Mon Jan 30, 2012 11:04 am
by Smivs
When using the 'setMaterials' js method you can switch a ship's texture 'on the fly'. What I would like to do though is switch texture A to texture B, but keep the same emission_map, and I don't know how to do this. Currently texture B is displaying, but without the emission_map.
I've tried several things, such as trying to 'set' the emission_map using the 'setMaterials' command, and have also tried various ways of specifying both texture/emission_map combinations in shipdata, but with no success.
Can this be done, and if so, how?

Re: Skinner’s Den

Posted: Mon Jan 30, 2012 3:31 pm
by JensAyton
Smivs wrote:
When using the 'setMaterials' js method you can switch a ship's texture 'on the fly'. What I would like to do though is switch texture A to texture B, but keep the same emission_map, and I don't know how to do this. Currently texture B is displaying, but without the emission_map.
I've tried several things, such as trying to 'set' the emission_map using the 'setMaterials' command, and have also tried various ways of specifying both texture/emission_map combinations in shipdata, but with no success.
Can this be done, and if so, how?
Something like:

Code: Select all

ship.setMaterials(
    {
        "smivs_supership_base_texture.png":
        {
            diffuse_map: "smivs_supership_alt_texture.png",
            emission_map: "smivs_supership_emission_map.png"
        }
    });

Re: Skinner’s Den

Posted: Mon Jan 30, 2012 4:02 pm
by Smivs
Excellent...that works a treat. Many thanks :)

Re: Skinner’s Den

Posted: Sat Feb 04, 2012 2:47 pm
by Smivs
I've hit an unexpected problem with this. It is working, but only for the 'main' ship. For example take the python. It works fine for "python" where the diffuse_map is switching nicely and the emission_map is remaining applied as intended. However if you use this for "python-trader" it doesn't work. Instead the texture is switching to the default python texture, and without the emission_map.
In other words if the ship in question is the main or base version (the one whose texture is specified in the .dat file) everything is fine, but if the ship in question is an alternative and has a different texture specified in the shipdata materials, things break down.
There is a connection here with the model file and the diffuse_map specified in the .dat file, and I have confirmed this with a bit of testing. In other words I can resolve the problem by using a seperate model for the individual varieties of these ships, but this seems a bit inelegant. Is there a better way of overcoming this problem?

Edit:- For now I've gone for the extra models option. :)

Re: Skinner’s Den

Posted: Sat Feb 11, 2012 10:03 am
by Capt. Murphy
A question closely related to Smivs' above -- :wink:

I'm trying to make a generic ship script that will do texture switching for a whole set of Smivs ships.

I've got some texture names defined as script_info keys.

e.g.

Code: Select all

script = "smivs-generic-ship-script.js";
	 script_info = {
				smivs_texture = "smivs'-anaconda.png";
				smivs_diffuse = "smivs'-anaconda-damaged.png";
				smivs_emission = "smivs'-anaconda_em-map.png";
			  };  
The models normal diffuse texture is "smivs'-anaconda.png"

In the script I've got

Code: Select all

this.shipEnergyIsLow = function()
{
    var texture = this.ship.scriptInfo.smivs_texture; // uses scriptInfo key to build texture name
	var diffuse = this.ship.scriptInfo.smivs_diffuse; // uses scriptInfo key to build diffuse map name
	var emission = this.ship.scriptInfo.smivs_emission; // uses scriptInfo key to build emission map name
    this.ship.setMaterials({texture: {diffuse_map: diffuse, emission_map: emission}}); // sets textures
}
This isn't throwing any errors, but it's not doing what I expect it too. The diffuse still appears to be "smivs'-anaconda.png", whilst the emission_map is going completely. Am I being dense or is it problematic for setMaterials to deal with strings as variables?

Edit to add, I've also tried this with the same result:

Code: Select all

this.shipEnergyIsLow = function()
{
    var texture = this.ship.scriptInfo.smivs_texture.quote(); // uses scriptInfo key to build texture name
	var diffuse = this.ship.scriptInfo.smivs_diffuse.quote(); // uses scriptInfo key to build diffuse map name
	var emission = this.ship.scriptInfo.smivs_emission.quote(); // uses scriptInfo key to build emission map name
    this.ship.setMaterials({texture: {diffuse_map: diffuse, emission_map: emission}}); // sets textures
}
Edit to add, sussed it.... :D (with a little peek at Svengali's MaterialsFinder1.0)

This works...

Code: Select all

this.shipEnergyIsLow = function()
{
    var texture = this.ship.scriptInfo.smivs_texture; // uses scriptInfo key to build texture name
	var diffuse = this.ship.scriptInfo.smivs_diffuse; // uses scriptInfo key to build diffuse map name
	var emission = this.ship.scriptInfo.smivs_emission; // uses scriptInfo key to build emission map name
	var material = new Object();
	material[texture] = {diffuse_map:diffuse, emission_map: emission};
    this.ship.setMaterials(material); // sets textures
}