History

Fix deferred lighting for rear view mirror.

Andrzej Kapolka committed 12 years ago

Commit e36ff0d1 parent f8772134 files · +19 −15Browse files

Showing the changes to interface/src/renderer/DeferredLightingEffect.cpp (1 of 4 files). Show all

Unified · Split

interface/src/renderer/DeferredLightingEffect.cpp+10−6
@@ -72,9 +72,13 @@ void DeferredLightingEffect::render() { · 71 unmodified lines
7272 int viewport[4];
7373 glGetIntegerv(GL_VIEWPORT, viewport);
7474 const int VIEWPORT_X_INDEX = 0;
75+ const int VIEWPORT_Y_INDEX = 1;
7576 const int VIEWPORT_WIDTH_INDEX = 2;
77+ const int VIEWPORT_HEIGHT_INDEX = 3;
7678 float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
7779 float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();
80+ float tMin = viewport[VIEWPORT_Y_INDEX] / (float)primaryFBO->height();
81+ float tHeight = viewport[VIEWPORT_HEIGHT_INDEX] / (float)primaryFBO->height();
7882
7983 ProgramObject* program = &_directionalLight;
8084 const LightLocations* locations = &_directionalLightLocations;
@@ -109,13 +113,13 @@ void DeferredLightingEffect::render() { · 28 unmodified lines
109113 program->setUniformValue(locations->nearLocation, nearVal);
110114 program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal);
111115 float nearScale = -1.0f / nearVal;
112− float sScale = 1.0f / sWidth;
113− float depthTexCoordScaleS = (right - left) * nearScale * sScale;
116+ float depthTexCoordScaleS = (right - left) * nearScale / sWidth;
117+ float depthTexCoordScaleT = (top - bottom) * nearScale / tHeight;
114118 program->setUniformValue(locations->depthTexCoordOffset, left * nearScale - sMin * depthTexCoordScaleS,
115− bottom * nearScale);
116− program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, (top - bottom) * nearScale);
119+ bottom * nearScale - tMin * depthTexCoordScaleT);
120+ program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, depthTexCoordScaleT);
117121
118− renderFullscreenQuad(sMin, sMin + sWidth);
122+ renderFullscreenQuad(sMin, sMin + sWidth, tMin, tMin + tHeight);
119123
120124 program->release();
121125
@@ -145,7 +149,7 @@ void DeferredLightingEffect::render() { · 23 unmodified lines
145149 glBindTexture(GL_TEXTURE_2D, freeFBO->texture());
146150 glEnable(GL_TEXTURE_2D);
147151
148− renderFullscreenQuad(sMin, sMin + sWidth);
152+ renderFullscreenQuad(sMin, sMin + sWidth, tMin, tMin + tHeight);
149153
150154 glBindTexture(GL_TEXTURE_2D, 0);
151155 glDisable(GL_TEXTURE_2D);