summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-11-08 13:11:29 -0600
committerDave Parks <davep@lindenlab.com>2011-11-08 13:11:29 -0600
commit428b74f14bd3763a6209d6a2132a8d7977958902 (patch)
treed443d5d3949aa831a4475cdbd08a45c5a79c0dbb
parent1bd09e2e42fbde3f00be2577b719bd172b4c9496 (diff)
SH-2652 Fix for black bands in high-res normal maps (break normal map generation up into tiles to handle the case where a normal map is higher resolution than the current window)
-rw-r--r--indra/newview/lldrawpoolbump.cpp60
1 files changed, 48 insertions, 12 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 7b9fb2b34b..b696b90d84 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -1363,6 +1363,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
{
LLFastTimer t(FTM_BUMP_SOURCE_GEN_NORMAL);
gPipeline.mScreen.bindTarget();
+
LLGLDepthTest depth(GL_FALSE);
LLGLDisable cull(GL_CULL_FACE);
LLGLDisable blend(GL_BLEND);
@@ -1377,22 +1378,57 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
gGL.getTexUnit(0)->bind(bump);
- gGL.begin(LLRender::TRIANGLE_STRIP);
+ S32 width = bump->getWidth();
+ S32 height = bump->getHeight();
+
+ S32 screen_width = gPipeline.mScreen.getWidth();
+ S32 screen_height = gPipeline.mScreen.getHeight();
+
+ glViewport(0, 0, screen_width, screen_height);
+
+ for (S32 left = 0; left < width; left += screen_width)
+ {
+ S32 right = left + screen_width;
+ right = llmin(right, width);
+
+ F32 left_tc = (F32) left/ width;
+ F32 right_tc = (F32) right/width;
+
+ for (S32 bottom = 0; bottom < height; bottom += screen_height)
+ {
+ S32 top = bottom+screen_height;
+ top = llmin(top, height);
+
+ F32 bottom_tc = (F32) bottom/height;
+ F32 top_tc = (F32)(bottom+screen_height)/height;
+ top_tc = llmin(top_tc, 1.f);
- gGL.texCoord2f(0, 0);
- gGL.vertex2f(0, 0);
- gGL.texCoord2f(0, 1);
- gGL.vertex2f(0, v.mV[1]);
- gGL.texCoord2f(1, 0);
- gGL.vertex2f(v.mV[0], 0);
- gGL.texCoord2f(1, 1);
- gGL.vertex2f(v.mV[0], v.mV[1]);
+ F32 screen_right = (F32) (right-left)/screen_width;
+ F32 screen_top = (F32) (top-bottom)/screen_height;
- gGL.end();
+ gGL.begin(LLRender::TRIANGLE_STRIP);
+ gGL.texCoord2f(left_tc, bottom_tc);
+ gGL.vertex2f(0, 0);
- gGL.flush();
+ gGL.texCoord2f(left_tc, top_tc);
+ gGL.vertex2f(0, screen_top);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bump->getWidth(), bump->getHeight());
+ gGL.texCoord2f(right_tc, bottom_tc);
+ gGL.vertex2f(screen_right, 0);
+
+ gGL.texCoord2f(right_tc, top_tc);
+ gGL.vertex2f(screen_right, screen_top);
+
+ gGL.end();
+
+ gGL.flush();
+
+ S32 w = right-left;
+ S32 h = top-bottom;
+
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, left, bottom, 0, 0, w, h);
+ }
+ }
glGenerateMipmap(GL_TEXTURE_2D);