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
72 int viewport[4];72 int viewport[4];
73 glGetIntegerv(GL_VIEWPORT, viewport);73 glGetIntegerv(GL_VIEWPORT, viewport);
74 const int VIEWPORT_X_INDEX = 0;74 const int VIEWPORT_X_INDEX = 0;
75 const int VIEWPORT_Y_INDEX = 1;
75 const int VIEWPORT_WIDTH_INDEX = 2;76 const int VIEWPORT_WIDTH_INDEX = 2;
77 const int VIEWPORT_HEIGHT_INDEX = 3;
76 float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();78 float sMin = viewport[VIEWPORT_X_INDEX] / (float)primaryFBO->width();
77 float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)primaryFBO->width();79 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();
78 82
79 ProgramObject* program = &_directionalLight;83 ProgramObject* program = &_directionalLight;
80 const LightLocations* locations = &_directionalLightLocations;84 const LightLocations* locations = &_directionalLightLocations;
@@ -109,13 +113,13 @@ void DeferredLightingEffect::render() { · 28 unmodified lines
109 program->setUniformValue(locations->nearLocation, nearVal);113 program->setUniformValue(locations->nearLocation, nearVal);
110 program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal);114 program->setUniformValue(locations->depthScale, (farVal - nearVal) / farVal);
111 float nearScale = -1.0f / nearVal;115 float nearScale = -1.0f / nearVal;
112 float sScale = 1.0f / sWidth;116 float depthTexCoordScaleS = (right - left) * nearScale / sWidth;
113 float depthTexCoordScaleS = (right - left) * nearScale * sScale;117 float depthTexCoordScaleT = (top - bottom) * nearScale / tHeight;
114 program->setUniformValue(locations->depthTexCoordOffset, left * nearScale - sMin * depthTexCoordScaleS,118 program->setUniformValue(locations->depthTexCoordOffset, left * nearScale - sMin * depthTexCoordScaleS,
115 bottom * nearScale);119 bottom * nearScale - tMin * depthTexCoordScaleT);
116 program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, (top - bottom) * nearScale);120 program->setUniformValue(locations->depthTexCoordScale, depthTexCoordScaleS, depthTexCoordScaleT);
117 121
118 renderFullscreenQuad(sMin, sMin + sWidth);122 renderFullscreenQuad(sMin, sMin + sWidth, tMin, tMin + tHeight);
119 123
120 program->release();124 program->release();
121 125
@@ -145,7 +149,7 @@ void DeferredLightingEffect::render() { · 23 unmodified lines
145 glBindTexture(GL_TEXTURE_2D, freeFBO->texture());149 glBindTexture(GL_TEXTURE_2D, freeFBO->texture());
146 glEnable(GL_TEXTURE_2D);150 glEnable(GL_TEXTURE_2D);
147 151
148 renderFullscreenQuad(sMin, sMin + sWidth);152 renderFullscreenQuad(sMin, sMin + sWidth, tMin, tMin + tHeight);
149 153
150 glBindTexture(GL_TEXTURE_2D, 0);154 glBindTexture(GL_TEXTURE_2D, 0);
151 glDisable(GL_TEXTURE_2D);155 glDisable(GL_TEXTURE_2D);