Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -181,6 +181,15 @@ void MetavoxelSystem::render() { · 180 unmodified lines | |||
| 181 | glActiveTexture(GL_TEXTURE1); | 181 | glActiveTexture(GL_TEXTURE1); |
| 182 | glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID()); | 182 | glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID()); |
| 183 | 183 | ||
| 184 | // get the viewport side (left, right, both) | ||
| 185 | int viewport[4]; | ||
| 186 | glGetIntegerv(GL_VIEWPORT, viewport); | ||
| 187 | const int VIEWPORT_X_INDEX = 0; | ||
| 188 | const int VIEWPORT_WIDTH_INDEX = 2; | ||
| 189 | QSize widgetSize = Application::getInstance()->getGLWidget()->getDeviceSize(); | ||
| 190 | float sMin = viewport[VIEWPORT_X_INDEX] / (float)widgetSize.width(); | ||
| 191 | float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)widgetSize.width(); | ||
| 192 | |||
| 184 | if (Menu::getInstance()->getShadowsEnabled()) { | 193 | if (Menu::getInstance()->getShadowsEnabled()) { |
| 185 | glActiveTexture(GL_TEXTURE2); | 194 | glActiveTexture(GL_TEXTURE2); |
| 186 | glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID()); | 195 | glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID()); |
| @@ -210,10 +219,13 @@ void MetavoxelSystem::render() { · 23 unmodified lines | |||
| 210 | program->setUniformValue(locations->nearLocation, nearVal); | 219 | program->setUniformValue(locations->nearLocation, nearVal); |
| 211 | program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal); | 220 | program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal); |
| 212 | float nearScale = -1.0f / nearVal; | 221 | float nearScale = -1.0f / nearVal; |
| 213 | program->setUniformValue(locations->depthTexCoordOffset, left * nearScale, bottom * nearScale); | 222 | float sScale = 1.0f / sWidth; |
| 214 | program->setUniformValue(locations->depthTexCoordScale, (right - left) * nearScale, (top - bottom) * nearScale); | 223 | float depthTexCoordScaleS = (right - left) * nearScale * sScale; |
| 224 | program->setUniformValue(locations->depthTexCoordOffset, left * nearScale - sMin * depthTexCoordScaleS, | ||
| 225 | bottom * nearScale); | ||
| 226 | program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, (top - bottom) * nearScale); | ||
| 215 | 227 | ||
| 216 | renderFullscreenQuad(); | 228 | renderFullscreenQuad(sMin, sMin + sWidth); |
| 217 | 229 | ||
| 218 | program->release(); | 230 | program->release(); |
| 219 | 231 | ||
| @@ -226,7 +238,7 @@ void MetavoxelSystem::render() { · 6 unmodified lines | |||
| 226 | 238 | ||
| 227 | } else { | 239 | } else { |
| 228 | _directionalLight.bind(); | 240 | _directionalLight.bind(); |
| 229 | renderFullscreenQuad(); | 241 | renderFullscreenQuad(sMin, sMin + sWidth); |
| 230 | _directionalLight.release(); | 242 | _directionalLight.release(); |
| 231 | } | 243 | } |
| 232 | 244 | ||
| @@ -245,7 +257,7 @@ void MetavoxelSystem::render() { · 12 unmodified lines | |||
| 245 | 257 | ||
| 246 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 258 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
| 247 | 259 | ||
| 248 | renderFullscreenQuad(); | 260 | renderFullscreenQuad(sMin, sMin + sWidth); |
| 249 | 261 | ||
| 250 | glBindTexture(GL_TEXTURE_2D, 0); | 262 | glBindTexture(GL_TEXTURE_2D, 0); |
| 251 | glDisable(GL_TEXTURE_2D); | 263 | glDisable(GL_TEXTURE_2D); |