Commit 24265b15 authored by monstrobishi's avatar monstrobishi

- Fixed the OpenGL normal mapping some more (Works properly now).

 - Fixed the OpenGL parallax mapping offset.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2776 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d21b1446
......@@ -60,15 +60,9 @@ const char OPENGL_NORMAL_MAP_VSH[] =
"MOV OutPos.z, Temp.z;\n"\
"MOV result.fogcoord.x, Temp.z;\n"\
"\n"\
"# vertex into world position \n"\
"DP4 Temp.x, InPos, program.local[0];\n"\
"DP4 Temp.y, InPos, program.local[1];\n"\
"DP4 Temp.z, InPos, program.local[2];\n"\
"DP4 Temp.w, InPos, program.local[3];\n"\
"\n"\
"# vertex - lightpositions \n"\
"SUB TempLightVector1, program.local[12], Temp; \n"\
"SUB TempLightVector2, program.local[14], Temp; \n"\
"SUB TempLightVector1, program.local[12], InPos; \n"\
"SUB TempLightVector2, program.local[14], InPos; \n"\
"\n"\
"# transform the light vector 1 with U, V, W \n"\
"DP3 TempTransLightV1.x, InTangent, TempLightVector1; \n"\
......
......@@ -63,18 +63,12 @@ const char OPENGL_PARALLAX_MAP_VSH[] =
"MOV OutPos.z, Temp.z;\n"\
"MOV result.fogcoord.x, Temp.z;\n"\
"\n"\
"# vertex into world position \n"\
"DP4 Temp.x, InPos, program.local[0];\n"\
"DP4 Temp.y, InPos, program.local[1];\n"\
"DP4 Temp.z, InPos, program.local[2];\n"\
"DP4 Temp.w, InPos, program.local[3];\n"\
"\n"\
"# vertex - lightpositions \n"\
"SUB TempLightVector1, program.local[12], Temp; \n"\
"SUB TempLightVector2, program.local[14], Temp; \n"\
"SUB TempLightVector1, program.local[12], InPos; \n"\
"SUB TempLightVector2, program.local[14], InPos; \n"\
"\n"\
"# eye vector \n"\
"SUB Temp, program.local[16], Temp; \n"\
"SUB Temp, program.local[16], InPos; \n"\
"\n"\
"# transform the light vector 1 with U, V, W \n"\
"DP3 TempTransLightV1.x, InTangent, TempLightVector1; \n"\
......@@ -293,17 +287,6 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi
const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed();
services->setVertexShaderConstant(tWorld.pointer(), 0, 4);
// The viewpoint is at (0., 0., 0.) in eye space.
// Turning this into a vector [0 0 0 1] and multiply it by
// the inverse of the view matrix, the resulting vector is the
// object space location of the camera.
f32 floats[4] = {0.0f,0.0f,0.0f,1.0f};
core::matrix4 minv(driver->getTransform(video::ETS_VIEW));
minv.makeInverse();
minv.multiplyWith1x4Matrix(floats);
services->setVertexShaderConstant(floats, 16, 1);
// set transposed worldViewProj matrix
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
worldViewProj *= driver->getTransform(video::ETS_VIEW);
......@@ -344,6 +327,15 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi
reinterpret_cast<const f32*>(&light.DiffuseColor), 13+(i*2), 1);
}
// Obtain the view position by transforming 0,0,0 by the inverse view matrix
// and then multiply this by the inverse world matrix.
core::vector3df viewPos(0.0f, 0.0f, 0.0f);
core::matrix4 inverseView;
driver->getTransform(video::ETS_VIEW).getInverse(inverseView);
inverseView.transformVect(viewPos);
invWorldMat.transformVect(viewPos);
services->setVertexShaderConstant(reinterpret_cast<const f32*>(&viewPos.X), 16, 1);
// set scale factor
f32 factor = 0.02f; // default value
if (CurrentScale != 0.0f)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment