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/scatter3drenderer.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/scatter3drenderer.cpp')
-rw-r--r-- | src/datavis3d/engine/scatter3drenderer.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/datavis3d/engine/scatter3drenderer.cpp b/src/datavis3d/engine/scatter3drenderer.cpp index a8d629b1..179d019c 100644 --- a/src/datavis3d/engine/scatter3drenderer.cpp +++ b/src/datavis3d/engine/scatter3drenderer.cpp @@ -54,9 +54,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 @@ -70,7 +70,8 @@ QT_DATAVIS3D_BEGIN_NAMESPACE #define DISPLAY_FULL_DATA_ON_SELECTION // Append selection value text with row and column labels -const GLfloat aspectRatio = 2.0f; // TODO: Calculate +const GLfloat aspectRatio = 1.66f; // TODO: Calculate +// TODO: Make margin modifiable? const GLfloat backgroundMargin = 1.1f; // Margin for background (1.1f = make it 10% larger to avoid items being drawn inside background) const GLfloat gridLineWidth = 0.005f; static QVector3D selectionSkipColor = QVector3D(255, 255, 255); // Selection texture's background color @@ -418,13 +419,19 @@ void Scatter3DRenderer::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(60.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 + //depthProjectionMatrix.ortho(-aspectRatio * 2.0f, aspectRatio * 2.0f, + // -m_heightNormalizer * 2.0f, m_heightNormalizer * 2.0f, + // 0.0f, 100.0f); + GLfloat testAspectRatio = (GLfloat)m_mainViewPort.width() / (GLfloat)m_mainViewPort.height(); + depthProjectionMatrix.ortho(-testAspectRatio * 2.0f, testAspectRatio * 2.0f, + -m_heightNormalizer * 2.0f, m_heightNormalizer * 2.0f, + 0.0f, 100.0f); #endif // Draw bars to depth buffer for (int bar = 0; bar < m_renderItemArray.size(); bar++) { |