diff options
Diffstat (limited to 'source/gameengine/Ketsji/BL_BlenderShader.cpp')
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index f5f9b344b87..3f2a9a6df6a 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -46,11 +46,20 @@ void BL_BlenderShader::ReloadMaterial() mGPUMat = (mMat) ? GPU_material_from_blender(mBlenderScene, mMat) : NULL; } -void BL_BlenderShader::SetProg(bool enable, double time) +void BL_BlenderShader::SetProg(bool enable, double time, RAS_IRasterizer* rasty) { if (VerifyShader()) { - if (enable) - GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1); + if (enable) { + assert(rasty != NULL); // XXX Kinda hacky, but SetProg() should always have the rasterizer if enable is true + + float viewmat[4][4], viewinvmat[4][4]; + const MT_Matrix4x4& view = rasty->GetViewMatrix(); + const MT_Matrix4x4& viewinv = rasty->GetViewInvMatrix(); + view.getValue((float*)viewmat); + viewinv.getValue((float*)viewinvmat); + + GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1, viewmat, viewinvmat); + } else GPU_material_unbind(mGPUMat); } @@ -120,7 +129,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) { - float obmat[4][4], viewmat[4][4], viewinvmat[4][4], obcol[4]; + float obmat[4][4], obcol[4]; GPUMaterial *gpumat; gpumat = mGPUMat; @@ -130,13 +139,9 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) MT_Matrix4x4 model; model.setValue(ms.m_OpenGLMatrix); - const MT_Matrix4x4& view = rasty->GetViewMatrix(); - const MT_Matrix4x4& viewinv = rasty->GetViewInvMatrix(); // note: getValue gives back column major as needed by OpenGL model.getValue((float*)obmat); - view.getValue((float*)viewmat); - viewinv.getValue((float*)viewinvmat); if (ms.m_bObjectColor) ms.m_RGBAcolor.getValue((float *)obcol); @@ -144,7 +149,7 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) obcol[0] = obcol[1] = obcol[2] = obcol[3] = 1.0f; float auto_bump_scale = ms.m_pDerivedMesh!=0 ? ms.m_pDerivedMesh->auto_bump_scale : 1.0f; - GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol, auto_bump_scale); + GPU_material_bind_uniforms(gpumat, obmat, obcol, auto_bump_scale); mAlphaBlend = GPU_material_alpha_blend(gpumat, obcol); } |