getInverse call failing

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

getInverse call failing

Post by robmar »

Using the sample from this forum for reflective water, which has both GLSL and HLSL shaders, under HLSL there is a failure on the call to getInverse, most of teh array is set to 0 or 0.001, element 15 is set to 1.0.

The result of the error alogn with the reflection being quadruplicated across the parallax node´s surface is something I´ve been unable to solve so far, if anyone has come across type of error this I´d really appreciate any tips.

Code: Select all

            // HLSL requires different world view processing
 
            mWorld = m_pDriver->getTransform(ETS_WORLD);
            services->setVertexShaderConstant("mWorld", mWorld.pointer(), 16);
            mView = m_pDriver->getTransform(ETS_VIEW);
            services->setVertexShaderConstant("mView", mView.pointer(), 16);
            mProjection = m_pDriver->getTransform(ETS_PROJECTION);
            mWorldViewProj = mProjection * mView;
            mWorldViewProj *= mWorld;
            services->setVertexShaderConstant("mWorldViewProj", mWorldViewProj.pointer(), 16);
 
            mWorld.getTransposed( mWorldTranspose );        // Set Inverse-Transposed world amtrix
            bool bRes = mWorldTranspose.getInverse( mWorldInverseTranspose );
            static bool bDisable = false;
            ASSERT( bRes || bDisable );
 
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: getInverse call failing

Post by chronologicaldot »

Out of curiosity, where did "mWorldInverseTranspose" get defined? If it's not of type CMatrix4, the call will fail because there is no getInverse() function that takes any other parameters but the one for CMatrix4.
Mikhail9
Posts: 54
Joined: Mon Jun 29, 2009 8:41 am

Re: getInverse call failing

Post by Mikhail9 »

robmar wrote:most of teh array is set to 0 or 0.001, element 15 is set to 1.0.
This could be why. A matrix that is very close to zero everywhere but one element is ill-conditioned and has no calculable inverse (or at least not one you can compute with limited computer precision). The behavior could be undefined and vary between GLSL and HLSL. It will also depend on where your 0.001 values are. Perhaps the matrix isn't being sent to the shader properly?
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: getInverse call failing

Post by robmar »

mWorldTranspose gets set here:-

mWorld.getTransposed( mWorldTranspose ); // Set Inverse-Transposed world matrix

or did I get that wrong??

Depending on camera distance to the reflection node, the problem goes away.

Also, if I add a node with a gooch shader, it also goes away.

What could be causing this...???
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: getInverse call failing

Post by robmar »

Found this, which solved the issue: http://irrlicht.sourceforge.net/forum/v ... se#p273807
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: getInverse call failing

Post by hybrid »

Well, in that case it should already be in the 1.8 release!?
Post Reply