Page 1 of 1

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

Posted: Sat Dec 06, 2014 12:42 pm
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

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

Posted: Sat Dec 06, 2014 3:11 pm
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.

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

Posted: Sun Dec 07, 2014 8:03 am
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 ?

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

Posted: Sun Dec 07, 2014 9:28 am
by mongoose7
True. But the materials have parameters. So you can create materials per node using the same shader.

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

Posted: Mon Dec 08, 2014 9:29 am
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.

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

Posted: Mon Dec 29, 2014 6:12 pm
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