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
Y Irrlicht does't have CallBack(setting uniforms) for nodes?
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Y Irrlicht does't have CallBack(setting uniforms) for nodes?
Last edited by vivekSivamRP on Sun Dec 07, 2014 7:58 am, edited 1 time in total.
Re: Y Irrlicht does't have CallBack(setting uniforms) for no
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.
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.
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: Y Irrlicht does't have CallBack(setting uniforms) for no
Oh sorry, I have made a mistake in my question statement
Edited the statement to1) 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.
And to your suggestion1) 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.
The case is to create a common shader for multiple Nodes, Which node will you pass as UserData while creating the common shader ?You can pass the node as user data when you create the shader.
Re: Y Irrlicht does't have CallBack(setting uniforms) for no
True. But the materials have parameters. So you can create materials per node using the same shader.
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: Y Irrlicht does't have CallBack(setting uniforms) for no
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.
Thank you.
Re: Y Irrlicht does't have CallBack(setting uniforms) for no
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
http://irrlicht.sourceforge.net/docu/cl ... nager.html
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt