Equivalent GLSL gl_ModelViewMatrix from Irrlicht Transforms.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
de3000
Posts: 20
Joined: Tue Sep 19, 2006 4:57 pm
Location: South Africa

Equivalent GLSL gl_ModelViewMatrix from Irrlicht Transforms.

Post by de3000 »

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 :P so does anybody know or should i try more multiplying nightmare-inducing code?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I believe it should be...

Code: Select all

core::matrix4 m = driver->getTransform(ETS_VIEW); 
m              *= driver->getTransform(ETS_WORLD);
Travis
de3000
Posts: 20
Joined: Tue Sep 19, 2006 4:57 pm
Location: South Africa

Post by de3000 »

I believed it was that also but debugging my shader says its not (unless my debug code is wrong).

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);
}
And in the shader
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;
}
Debug.frag

Code: Select all

varying vec4 same;
void main()
{
	gl_Colour=same;
}
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.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Code: Select all

matrix4 proj= services->getVideoDriver()->getTransform(video::ETS_WORLD); 
Lol.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
de3000
Posts: 20
Joined: Tue Sep 19, 2006 4:57 pm
Location: South Africa

Post by de3000 »

:oops: Copy paste fail.

de3000 wrote:unless my debug code is wrong


Guess it is wrong. Still having trouble getting comparable results though.
Post Reply