diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-08-07 09:11:30 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-08-07 09:18:52 +0300 |
commit | b2ad88e33a93a491250443b200dbba22b3870782 (patch) | |
tree | 1f17e35ec6e7a3a61427fe90d5481b7842c11f52 /src/datavis3d/engine/bars3drenderer.cpp | |
parent | d727554e22112657c447e855589847743622716c (diff) |
Fix for shadow angling bug
Task-number: QTRD-2130
+ added an option to use orthographic shadows, but using them would
require shader changes and some more tweaking
Change-Id: Ibf54f43daebbf136422284528588e5a6eecc4538
Change-Id: Ibf54f43daebbf136422284528588e5a6eecc4538
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavis3d/engine/bars3drenderer.cpp')
-rw-r--r-- | src/datavis3d/engine/bars3drenderer.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/datavis3d/engine/bars3drenderer.cpp b/src/datavis3d/engine/bars3drenderer.cpp index 9cabd7a2..6ed63d9b 100644 --- a/src/datavis3d/engine/bars3drenderer.cpp +++ b/src/datavis3d/engine/bars3drenderer.cpp @@ -57,9 +57,9 @@ #include <QDebug> #include <QMutexLocker> -// Uncommenting this draws the shadow map with wider FOV than scene itself, making the light -// seem to be closer to scene than it actually is. This way shadows look slightly better (to me anyway) -#define USE_WIDER_SHADOWS +// Commenting this draws the shadow map with perspective projection. Otherwise it's drawn in +// orthographic projection. +//#define USE_WIDER_SHADOWS // You can verify that depth buffer drawing works correctly by uncommenting this. // You should see the scene from where the light is @@ -622,13 +622,17 @@ void Bars3dRenderer::drawScene(CameraHelper *camera, // TODO: Why does depthViewMatrix.column(3).y() goes to zero when we're directly above? That causes the scene to be not drawn from above -> must be fixed //qDebug() << lightPos << depthViewMatrix << depthViewMatrix.column(3); // Set the depth projection matrix -#ifdef USE_WIDER_SHADOWS - // Use this for a bit exaggerated shadows - depthProjectionMatrix.perspective(20.0f, (GLfloat)m_mainViewPort.width() +#ifndef USE_WIDER_SHADOWS + // Use this for perspective shadows + depthProjectionMatrix.perspective(15.0f, (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height(), 3.0f, 100.0f); #else - // Use these for normal shadows, with the light further away - depthProjectionMatrix = projectionMatrix; + // Use these for orthographic shadows + //GLfloat testAspectRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height(); + //qDebug() << m_autoScaleAdjustment << m_yAdjustment; + depthProjectionMatrix.ortho(-2.0f * 2.0f, 2.0f * 2.0f, + -2.0f, 2.0f, + 0.0f, 100.0f); #endif // Draw bars to depth buffer for (int row = startRow; row != stopRow; row += stepRow) { @@ -819,7 +823,6 @@ void Bars3dRenderer::drawScene(CameraHelper *camera, glDisable(GL_TEXTURE_2D); m_labelShader->release(); #endif - } // Enable texturing @@ -875,8 +878,7 @@ void Bars3dRenderer::drawScene(CameraHelper *camera, GLfloat lightStrength = m_cachedTheme.m_lightStrength; if (m_cachedSelectionMode > ModeNone) { - - Bars3dController::SelectionType selectionType = isSelected(row, bar); + Bars3dController::SelectionType selectionType = isSelected(row, bar); switch (selectionType) { case Bars3dController::SelectionBar: { |