how can I supply parameter to shader?

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
bongse1
Posts: 14
Joined: Mon Jul 26, 2010 11:41 am

how can I supply parameter to shader?

Post by bongse1 »

To implement shader,we need to implement
"IShaderConstantSetCallBack" class.
In this class ,the method looks like below,

virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{..}
how can I supply "s32 userData" parameter from outside?
Is this the only way,and the right way to supply constants to shader from outside?

for example;
given that there are several scene nodes,and I want to supply different constants to each shader of each scene node.How can I achieve this?
I think there is a way we can supply the "s32 userData" parameter of above method of "IShaderConstantSetCallBack" class above?
Am i right? so we implement it inside the above method to supply different constants.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

You can also implement OnSetMaterial and use

MaterialTypeParam
MaterialTypeParam2

for individual nodes, like so
http://irrlicht.sourceforge.net/docu/cl ... _back.html

userdata is set in

addHighLevelShaderMaterialFromFiles

(last parameter)
Never take advice from someone who likes to give advice, so take my advice and don't take it.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Really, you can use any data in a SMaterial for shader data. A good example would be to use the Shininess member as a specular coefficient for Phong lighting.
Post Reply