I did a little search but i couldn´t find the answer...
Can Irrlicht load .fx files generated from fx composer or rendermonkey or shader fx???
thanks
can Irrlicht load .fx files??
hey thanks...
But with Irrlicht do I have acess to all the variables that I need to implement a shader, like the world, worlviewprojection, view projection, view, etc ??
(the reson I am asking this is because I was currently using TGEA to work with shaders but I didint have acess to a lot of variables that I nedded in order to implement a shader on it)
But with Irrlicht do I have acess to all the variables that I need to implement a shader, like the world, worlviewprojection, view projection, view, etc ??
(the reson I am asking this is because I was currently using TGEA to work with shaders but I didint have acess to a lot of variables that I nedded in order to implement a shader on it)
Code: Select all
class MyShaderCallBack : public video::IShaderConstantSetCallBack
{
public:
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 invWorld = driver->getTransform(video::ETS_WORLD);
invWorld.makeInverse();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mInvWorld", invWorld.pointer(), 16);
else
services->setVertexShaderConstant(invWorld.pointer(), 0, 4);
// set clip matrix
core::matrix4 worldViewProj;
worldViewProj = driver->getTransform(video::ETS_PROJECTION);
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
if (UseHighLevelShaders)
services->setVertexShaderConstant("mWorldViewProj", worldViewProj.pointer(), 16);
else
services->setVertexShaderConstant(worldViewProj.pointer(), 4, 4);
// set camera position
core::vector3df pos = device->getSceneManager()->
getActiveCamera()->getAbsolutePosition();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mLightPos", reinterpret_cast<f32*>(&pos), 3);
else
services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 8, 1);
// set light color
video::SColorf col(0.0f,1.0f,1.0f,0.0f);
if (UseHighLevelShaders)
services->setVertexShaderConstant("mLightColor", reinterpret_cast<f32*>(&col), 4);
else
services->setVertexShaderConstant(reinterpret_cast<f32*>(&col), 9, 1);
// set transposed world matrix
core::matrix4 world = driver->getTransform(video::ETS_WORLD);
world = world.getTransposed();
if (UseHighLevelShaders)
services->setVertexShaderConstant("mTransWorld", world.pointer(), 16);
else
services->setVertexShaderConstant(world.pointer(), 10, 4);
}
};
The answer to your question is yes. Irrlicht allows you to set the variables that you have defined in your shader file. Take note of how is gets the worldViewProj matrix.
Code: Select all
core::matrix4 worldViewProj;
worldViewProj = driver->getTransform(video::ETS_PROJECTION);
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
if (UseHighLevelShaders)
services->setVertexShaderConstant("mWorldViewProj", worldViewProj.pointer(), 16);
Code: Select all
uniform mat4 mWorldViewProj;
TheQuestion = 2B || !2B
That's great. I'm surprised that TGEA can not do this stuff...as I have seen people use a lot of complicated shaders with TGEA. But, eh, I have never used it.mjoselli wrote:Thanks a lot...
I will probably change from TGEA to Irrlicht, now that I know that Irrlicht can do the things that I want to do...
Either way, welcome to the community!
TheQuestion = 2B || !2B