getting scene node in shader callback
-
- Posts: 269
- Joined: Tue Oct 31, 2006 3:24 pm
- Contact:
getting scene node in shader callback
hi all.
i have a phong GLSL shader that support infinite lights trought array, but i would like to calculate only two nearest lights from node. to do this i have no problem to insert the lights into an array but i have to know what node is going to pass trought the shader, to compute the distance between the node and all the lights.
unfortunately IShaderConstantSetCallBack has no parameters for the scene node. i can use user data by setting user data as node id. but user data is create with material, so different materials have different user data. so if i have 999 nodes in my scene? i have to create 999 different materials?
So my question is: how can i get scene node from IShaderConstantSetCallBack ?
Please help me
Greetings
i have a phong GLSL shader that support infinite lights trought array, but i would like to calculate only two nearest lights from node. to do this i have no problem to insert the lights into an array but i have to know what node is going to pass trought the shader, to compute the distance between the node and all the lights.
unfortunately IShaderConstantSetCallBack has no parameters for the scene node. i can use user data by setting user data as node id. but user data is create with material, so different materials have different user data. so if i have 999 nodes in my scene? i have to create 999 different materials?
So my question is: how can i get scene node from IShaderConstantSetCallBack ?
Please help me
Greetings
Code: Select all
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
// set inverted world matrix
// if we are using highlevel shaders (the user can select this when
// starting the program), we must set the constants by name.
core::matrix4 World = driver->getTransform(video::ETS_WORLD);
-
- Posts: 269
- Joined: Tue Oct 31, 2006 3:24 pm
- Contact:
Thanks.
this solve the problem, but so is there noways to get the node wich current shader is applied? for example i create a high level material called 'g' and assign it to 10 nodes. Is there a method to get in shader constant callback the node among 10 nodes wich the shader is applied to?
Thanks for answering
this solve the problem, but so is there noways to get the node wich current shader is applied? for example i create a high level material called 'g' and assign it to 10 nodes. Is there a method to get in shader constant callback the node among 10 nodes wich the shader is applied to?
Thanks for answering
Since you can always add something like this directly to your main loop, it isn't always certain that the thing being drawn is drawn from a node. So in other words, not in irrlicht, at least until you've made your own hack to solve the problem
(Code copy-pasted from example 3)
Code: Select all
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
Well, i thought of a hack. but it requires a dll mod.
Add a pointer to a scenenode in the scenemanager class. and then on Prender call of the shaded node set the pointer in the scenemanager to that node
smgr->Shadednode=this.
then call that pointer out of the set constants (which can get the scenemanger via device)
In short:
so you just make a pointer in the scenemanger which on rendering a node is set to point to that node. Then the constants callback checks the pointer in smgr to get the current node being renderd.
Btw one thing my experiments with infinite lights taught me, is that on pre shader model three cards you can only send very few uniforms and varyings. and lights eat up a lot of floats esp with lots of options like pos, colour, radius, falloff etc...
Add a pointer to a scenenode in the scenemanager class. and then on Prender call of the shaded node set the pointer in the scenemanager to that node
smgr->Shadednode=this.
then call that pointer out of the set constants (which can get the scenemanger via device)
In short:
so you just make a pointer in the scenemanger which on rendering a node is set to point to that node. Then the constants callback checks the pointer in smgr to get the current node being renderd.
Btw one thing my experiments with infinite lights taught me, is that on pre shader model three cards you can only send very few uniforms and varyings. and lights eat up a lot of floats esp with lots of options like pos, colour, radius, falloff etc...
"Irrlicht is obese"
If you want modern rendering techniques learn how to make them or go to the engine next door =p
If you want modern rendering techniques learn how to make them or go to the engine next door =p
Nvidia cg toolkit, the refrence manual covers mainly cg but also details the shader models(and covers some diffrences in the api's of ogl and dx in respect to shaders) just use search on pdf.
Best way to deal with refrence manuals is not to read them sequientally lol.
Best way to deal with refrence manuals is not to read them sequientally lol.
"Irrlicht is obese"
If you want modern rendering techniques learn how to make them or go to the engine next door =p
If you want modern rendering techniques learn how to make them or go to the engine next door =p