I am trying to find the GLSL gl_ModelViewMatrix by multiplying the matrices from getTransfom() but I am getting nowhere.
Debugging shaders is not fun so does anybody know or should i try more multiplying nightmare-inducing code?
Equivalent GLSL gl_ModelViewMatrix from Irrlicht Transforms.
I believe it should be...
Travis
Code: Select all
core::matrix4 m = driver->getTransform(ETS_VIEW);
m *= driver->getTransform(ETS_WORLD);
I believed it was that also but debugging my shader says its not (unless my debug code is wrong).
Setting callback
And in the shader
Debug.vert
Debug.frag
So basically I just set a channel to 1.0 if the matrices match up and from my output most objects appear blue except for one which is placed at the origin.
What I am trying to do is render a scene from one camera view (Camera A) and store gl_ModelViewMatrix*gl_Vertex and then from another view (Camera B) calculate cameraAModelViewMatrix*gl_Vertex so that a comparison can be done.
Setting callback
Code: Select all
virtual void OnSetConstants(irr::video::IMaterialRendererServices* services,irr::s32 userData)
{
matrix4 world= services->getVideoDriver()->getTransform(video::ETS_PROJECTION);
matrix4 proj= services->getVideoDriver()->getTransform(video::ETS_WORLD);
matrix4 view= services->getVideoDriver()->getTransform(video::ETS_VIEW);
services->setVertexShaderConstant("mWorld", world.pointer(), 16);
services->setVertexShaderConstant("mProj", proj.pointer(), 16);
services->setVertexShaderConstant("mView", view.pointer(), 16);
}
Debug.vert
Code: Select all
uniform mat4 mProj, mWorld, mView;
varying vec4 same;
void main()
{
gl_Position = ftransform();
mat4 a,b,c;
a=mWorld;
b=mProj;
c=mView;
mat4 ab,ba,ac,bc,ca,cb;
ab=a*b;
ba=b*a;
ac=a*c;
bc=b*c;
ca=c*a;
cb=c*b;
same.r=(gl_ModelViewMatrix==(bc))?1.0:0.0;
same.g=(gl_ModelViewMatrix==(ca))?1.0:0.0;
same.b=(gl_ModelViewMatrix==(cb))?1.0:0.0;
}
Code: Select all
varying vec4 same;
void main()
{
gl_Colour=same;
}
What I am trying to do is render a scene from one camera view (Camera A) and store gl_ModelViewMatrix*gl_Vertex and then from another view (Camera B) calculate cameraAModelViewMatrix*gl_Vertex so that a comparison can be done.
Code: Select all
matrix4 proj= services->getVideoDriver()->getTransform(video::ETS_WORLD);
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net