yv wrote:I would like to pass a few variable to the vertex and pixel shaders within Irrlicht. When I use GLSL shaders, I can pass variables just fine.
When I use HLSL shaders the simplest example from docs fails to compile.
Can someone shed some light on what is going on?
See me trying to pass fTime to the shader below.
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 invWorld = driver->getTransform(video::ETS_WORLD); invWorld.makeInverse(); if (UseHighLevelShaders) services->setVertexShaderConstant("mInvWorld", &invWorld.M[0], 16); // 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.M[0], 16); // set camera position core::vector3df pos = device->getSceneManager()->getActiveCamera()->getAbsolutePosition(); if (UseHighLevelShaders) services->setVertexShaderConstant("mLightPos", reinterpret_cast<f32*>(&pos), 3); // set light color video::SColorf col(1.0f,0.0f,0.0f,0.0f); if (UseHighLevelShaders) services->setVertexShaderConstant("mLightColor", reinterpret_cast<f32*>(&col), 4); // set transposed world matrix core::matrix4 world = driver->getTransform(video::ETS_WORLD); world = world.getTransposed(); if (UseHighLevelShaders) services->setVertexShaderConstant("mTransWorld", &world.M[0], 16); if (UseHighLevelShaders) { f32 time = (f32)device->getTimer()->getTime()/100000.0f; services->setVertexShaderConstant("fTime", &time, 1); }
Here is the declaration of the variable inside the hlsl file:
Here is the repeating error I get on the console:Code: Select all
... float fTime; ...
HLSL Variable to set not found: 'fTime'. Available variables are:
'mInvWorld' Registers:[begin:8, count:3]
'mLightColor' Registers:[begin:12, count:1]
'mLightPos' Registers:[begin:11, count:1]
'mTransWorld' Registers:[begin:4, count:4]
'mWorldViewProj' Registers:[begin:0, count:4]
Please help!
Kalda wrote:Yes. It's true... I have same problem. Please move this post to Bug Reports please.