Multiple shaders on one object

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
tank202
Competition winner
Posts: 40
Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas

Multiple shaders on one object

Post by tank202 »

Hello,

I want to apply specific sets of shaders on one object. For example:
Object 1 - displacement, object motion blur.
Object 2 - color pass, object motion blur.

How can I do this ?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Multiple shaders on one object

Post by CuteAlien »

You can either give your object different materials or you can pass per-object parameters to your shaders and switch in there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Multiple shaders on one object

Post by The_Glitch »

I was wondering this also I have been making and improving shaders and I did notice that you can not apply more than one shader to an object or 1 node. For example:

Code: Select all

node->setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
Will allow you set apply the shader to different materials on your node. However if you want an object to use another shader for lets say arms and legs, setting

Code: Select all

 node>getMaterial(2).setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
will not work I'm not sure why my guess could be that the first line of code is trying to apply that one shader to the whole object, and is overriding the second line of code. Though I have tried

Code: Select all

 node>getMaterial(1).setMaterialType((video::E_MATERIAL_TYPE)newMaterialType1);
,

Code: Select all

 node>getMaterial(2).setMaterialType((video::E_MATERIAL_TYPE)newMaterialType2);
, but that doesn't work either, so I assumed you could only use one shader per node or object.
tank202
Competition winner
Posts: 40
Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas

Re: Multiple shaders on one object

Post by tank202 »

Well I see... Its not possible to apply several shaders to one object...

And what about multiple passes?
Shelling requires HLSL script support but as irrlicht will most likely wont support it either, I would like to know if I can make the shader execute multiple passes in one rendering?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Multiple shaders on one object

Post by mongoose7 »

Well, the important code is 'node->render', so if you write your own render loop, you can render multiple times.

But, why do you need more than one shader? Just combine all your shaders into one and set some uniforms.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Multiple shaders on one object

Post by CuteAlien »

Shaders are materials. So I think you can set as many shaders as your project has materials (or meshbuffers).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply