Commit 04347e14 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

make campos and camdir available in shaders

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3239eec6
......@@ -421,6 +421,14 @@ int IRenderer::cmpPriority(const void* _a, const void* _b)
void IRenderer::prepareRenderingPipeline(ACG::GLState* _glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ACG::SceneGraph::BaseNode* _scenegraphRoot)
// grab view transform from glstate
viewMatrix_ = _glState->modelview();
camPosWS_ = Vec3f( viewMatrix_(0,3), viewMatrix_(1,3), viewMatrix_(2,3) );
camDirWS_ = Vec3f( viewMatrix_(0,2), viewMatrix_(1,2), -viewMatrix_(2,2) ); // mind the z flip
// printf("pos: %f %f %f\ndir: %f %f %f\n", camPosWS_[0], camPosWS_[1], camPosWS_[2],
// camDirWS_[0], camDirWS_[1], camDirWS_[2]);
// First, all render objects get collected.
collectRenderObjects(_glState, _drawMode, _scenegraphRoot);
......@@ -702,6 +710,8 @@ void IRenderer::bindObjectUniforms( ACG::RenderObject* _obj, GLSL::Program* _pro
_prog->setUniformMat3("g_mWVIT", mvIT);
_prog->setUniform("g_mP", _obj->proj);
_prog->setUniform("g_vCamPos", camPosWS_);
_prog->setUniform("g_vCamDir", camDirWS_);
// material
......@@ -471,6 +471,15 @@ protected:
/// currently active viewer ID as specified in prepareRenderObjects()
int curViewerID_;
/// view transform
GLMatrixf viewMatrix_;
/// cam position in world-space
Vec3f camPosWS_;
/// direction the camera is looking to in world-space
Vec3f camDirWS_;
/// previous fbo
GLint prevFbo_;
Supports Markdown
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