Y Irrlicht does't have CallBack(setting uniforms) for nodes?

A forum to store posts deemed exceptionally wise and useful
Post Reply
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Y Irrlicht does't have CallBack(setting uniforms) for nodes?

Post by vivekSivamRP »

Would't it be efficient if irrlicht has ShaderCallBacks for Nodes rather than for MaterialRenderers ?
Consider this case: Nodes [A1,A2.....An] want to use single shader and different callback classes (for setting the node properties/uniforms). For loading the shader in irrlicht we need to pass the callback class object as an argument.
The problem is
1) In Irrlicht we can not use a common callback class for all the Nodes[A1...An], because each nodes have different values for properties/uniforms to pass to shaders.
2) Even if we use a common callback class for all Nodes, we cannot identify for which node the onSetMaterial(..)/OnSetConstant(..) has been called ?

Because of this issue i've loaded same shaders for multiple times Shaders[S1,S2...Sn] for Nodes[A1,....An] with callback Instance[C1....Cn]. But loading many shaders consumes more memory. To avoid loading same shader for multiple times, My suggestion is to have callbacks for nodes rather than for shaders.

Is there any other way in irrlicht for this case ? Please share if.Sorry if i'm unaware about new methods.

Thank you
Last edited by vivekSivamRP on Sun Dec 07, 2014 7:58 am, edited 1 time in total.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Y Irrlicht does't have CallBack(setting uniforms) for no

Post by mongoose7 »

You can pass the node as user data when you create the shader.

You do know, don't you, that your question makes no sense. If the nodes have different properties/uniforms, then they need different shaders. If they can use the same shader, you just need an identifier to select the behaviour of the shader. Use the user data field as an indirect reference for the behaviour you require.
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Y Irrlicht does't have CallBack(setting uniforms) for no

Post by vivekSivamRP »

Oh sorry, I have made a mistake in my question statement
1) In Irrlicht we can not use a common callback class for all the Nodes[A1...An], because each nodes have different properties/uniforms to pass to shaders.
Edited the statement to
1) In Irrlicht we can not use a common callback class for all the Nodes[A1...An], because each nodes have different values for the properties/uniforms to pass to shaders.
And to your suggestion
You can pass the node as user data when you create the shader.
The case is to create a common shader for multiple Nodes, Which node will you pass as UserData while creating the common shader ?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Y Irrlicht does't have CallBack(setting uniforms) for no

Post by mongoose7 »

True. But the materials have parameters. So you can create materials per node using the same shader.
vivekSivamRP
Posts: 66
Joined: Sat Sep 29, 2012 11:58 am

Re: Y Irrlicht does't have CallBack(setting uniforms) for no

Post by vivekSivamRP »

Ok it is fine. During the shadercallback irrlicht first calls OnSetMaterial(SMaterial &material) and then calls OnSetConstant(..). So we can use material parameter in OnSetMaterial(..) to identify the node and set the properties according to that.

Thank you.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Y Irrlicht does't have CallBack(setting uniforms) for no

Post by Mel »

Take a look at the light manager interface, there is a method, the OnNodePreRender() which is called for every scene node just BEFORE its rendering, and also, there is another method, the OnNodePostRender(), called AFTER the node is rendered. You could implement a light manager and somehow "warn" your application about certain nodes being rendered, making it much simpler the identification process.

http://irrlicht.sourceforge.net/docu/cl ... nager.html
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply