As the venture in the realm of Shaders and materials you may encounter the odd obstacle. Please post your shader issue for the community to help.

Material Inheritance

Material Inheritance

Postby Shando » 20 Sep 2013, 05:02

Hi All,

I have been reading the Ogre Manual :geek: and I think I'm beginning to understand Materials better now :)

Just one question:

If I have the same Material used in many different .material files, can I just use the Inheritance features instead of typing it all out?

For example I currently have something like this in multiple .material files:

Code: Select all
material cp_mat_3_adv : Base_Multilight_V1
{
   set $diffuseMap "hull_b.dds"
   set $normalMap "Blank_N.jpg"
   set $specularMap "black.dds"
   set $UV_Scale "1 1 0"
   set $diffuse_tint_color "0.470588 0.470588 0.470588 1"
   set $rimlight_tint_color "1 1 1"
   set $diffuseParam "1 0 0"
   set $normalParam "0 1.5 0"
   set $misc1 "1.53 22 0 1"
   set $RimLight_Params "2.5 2.5 0.3 3"
   set $LodDistance_0 "50"
   set $UV_LodScale "1 1"
}


Can I just reference the first instance of this Material (in "biosphere_b.material") and use something like this in all other .material files:

Code: Select all
import * from "biosphere_b.material"
material cp_mat_3_adv : bio_mat_2_adv
{
}


and then, when I need to change a Texture (such as the colour) I just include the relevant line(s) between the {}?

I assume that doing this (if it works) will mean that I can't use the Material Editor?

The main reason I ask is that I currently have approx. 10 different Materials x 12 different Models x 4 different colours (for a total of almost 600 Material instances), and if I decide to slightly change 1 Material I may have to update upwards of 20-30 instances of the Material.

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Material Inheritance

Postby SolarPortal » 20 Sep 2013, 12:44

wow, someone's got to full material scripting. :P

in ogre3d, you cannot keep inheriting scripts down. It can only be done once:
e.g.
myMaterial_adv : Base_MultiLight_V1- This works
mynewMAterial_adv : myMaterial_adv - This doesn't work.

What you could do is copy the Base_Multilight_V1 material file in the base shaders folder and rename the material. Let it reference the same vertex and fragment programs aswell as reference the same vertex and pixel shaders. Which means all you need to do is rename the material and change the set $blah ""

You can locate the base shaders in the "SkylineSDK\Skyline\Data\Shaders\Skyline Base Shaders".

Steps:
> Open location above
> Copy the Base_Multilight_V1 folder, delete everything other than the materials(also delete the _selected and TEST version as that is in dev), then rename to your own material names.
> Rename the material filenames to your own.. e.g. shando_baseMaterial_Faction_xxx_b.material
> Copy this name and copy this name to the material inside the .material (where it says Base_Multilight_V1 inside the file)
> Do this for all the Alpha material versions aswell.
> Dont change any of the programs or shaders as you want to use the skyline look on objects.
> Change all the set $blah "" to your settings, which means the base material you inherit from uses these settings.
> restart skyline
> Add model and material as normal. Set the property "use custom base material" and set the new base material name in the line edit.
> Save material and material should use the new custom base material.

New features required.
In your post you wanted to reference an already made material without having to set any of the set $blah "" properties.
Today i will add into the material editor the ability to not export any of these settings apart from the ones you want like textures etc..
That way your material will export without the set properties and reference the base material you have setup.

Note: The base shaders do not need to be stored in the Data\Shaders folder. That is why there is the Shaders folder in the Asset Library, or project.

Skyline has been designed this way, so pro material writers from ogre3d have complete control over their games look as they can edit the entire base material and shaders to look completely different, or use the base shaders to have skylines look and performance, but still use their own base materials which might have extra features.

All we ask to developers is that if they make a really cool shader that makes skyline look even better, then pass it back to us so we can improve skyline aswell. :D

Note: I will write a tutorial on this today :D

Hope this Helps
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Material Inheritance

Postby SolarPortal » 21 Sep 2013, 11:37

ok, i have now added these features in code.

i shall write up some documentation today on how to inherit from your own base material and still use the material editor for your changes. This saves you from having to write everything out manually.
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Material Inheritance

Postby SolarPortal » 21 Sep 2013, 22:20

i have just finished writing the "Creating your own base material" documents now.

http://www.chi-ad.com/DokuWiki/doku.php/english_manual:ms_material_creating_base_materials

I will release the patch tonight or tomorrow so you have the updated features.
Hope this helps :D
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Material Inheritance

Postby Shando » 21 Sep 2013, 22:31

Hi SolarPortal,

I'll check it out now :)

Regards

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Material Inheritance

Postby SolarPortal » 23 Sep 2013, 10:33

The latest patch release has the latest feature changes that work with the documents posted before
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Material Inheritance

Postby Shando » 26 Sep 2013, 02:03

Hi Guys,

Finally managed to get some time on the computer :D

I have just tried my "multiple inheritance" material and it works!!!!!!

Here's my new base material:

http://sdrv.ms/19AG21H

My new material:

http://sdrv.ms/19AG7T4

And finally the view in Skyline:

http://sdrv.ms/19AGb5i

I've also checked the Material Editor, and everything seems to come through fine, even the inherited materials are displayed in the correct places :mrgreen:

Now all I've got to do is convert all my other materials to match :?

Keep up the excellent work.

Shando
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Material Inheritance

Postby SolarPortal » 28 Sep 2013, 11:45

great, thanks very much :D
its nice to see it was easy to adapt into your workflow.

i looked through your files and everything seems to be in place :P

have fun!
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Shaders n Materials

Who is online

Users browsing this forum: No registered users and 3 guests