History

Fix for deferred lighting with 3DTV (/Oculus, although I haven't tested that yet).

Andrzej Kapolka committed 12 years ago

Commit 2fde67b1 parent f3b8d681 file · +17 −5Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+17−5
@@ -181,6 +181,15 @@ void MetavoxelSystem::render() { · 180 unmodified lines
181181 glActiveTexture(GL_TEXTURE1);
182182 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryNormalTextureID());
183183
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+
184193 if (Menu::getInstance()->getShadowsEnabled()) {
185194 glActiveTexture(GL_TEXTURE2);
186195 glBindTexture(GL_TEXTURE_2D, Application::getInstance()->getTextureCache()->getPrimaryDepthTextureID());
@@ -210,10 +219,13 @@ void MetavoxelSystem::render() { · 23 unmodified lines
210219 program->setUniformValue(locations->nearLocation, nearVal);
211220 program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal);
212221 float nearScale = -1.0f / nearVal;
213− program->setUniformValue(locations->depthTexCoordOffset, left * nearScale, bottom * nearScale);
214− program->setUniformValue(locations->depthTexCoordScale, (right - left) * nearScale, (top - bottom) * nearScale);
222+ float sScale = 1.0f / sWidth;
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);
215227
216− renderFullscreenQuad();
228+ renderFullscreenQuad(sMin, sMin + sWidth);
217229
218230 program->release();
219231
@@ -226,7 +238,7 @@ void MetavoxelSystem::render() { · 6 unmodified lines
226238
227239 } else {
228240 _directionalLight.bind();
229− renderFullscreenQuad();
241+ renderFullscreenQuad(sMin, sMin + sWidth);
230242 _directionalLight.release();
231243 }
232244
@@ -245,7 +257,7 @@ void MetavoxelSystem::render() { · 12 unmodified lines
245257
246258 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
247259
248− renderFullscreenQuad();
260+ renderFullscreenQuad(sMin, sMin + sWidth);
249261
250262 glBindTexture(GL_TEXTURE_2D, 0);
251263 glDisable(GL_TEXTURE_2D);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t