summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-06-19 14:34:52 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-06-19 14:37:50 -0600
commit21177c8764638e1d4b3b29fed64adec62a14e936 (patch)
treed8b93152cf1c411e37af65d5ff9bb45373765081 /src
parentcf29ab3ba075905cca786b52617d7dc993f58033 (diff)
mesa: tweak mipmap level selection for cube maps
This is just a hack. After we convert the 3D texcoord into a face plus 2D texcoord we need to recompute the partial derivatives and mipmap LOD. But we don't have the info to do that. Adjusting the original mipmap level by -1 seems to give somewhat better results than before though.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_texfilter.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index a5594ac623..c9e9db132f 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -1854,8 +1854,19 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx,
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
- GLint level = nearest_mipmap_level(tObj, lambda[i]);
+ GLint level;
images = choose_cube_face(tObj, texcoord[i], newCoord);
+
+ /* XXX we actually need to recompute lambda here based on the newCoords.
+ * But we would need the texcoords of adjacent fragments to compute that
+ * properly, and we don't have those here.
+ * For now, do an approximation: subtracting 1 from the chosen mipmap
+ * level seems to work in some test cases.
+ * The same adjustment is done in the next few functions.
+ */
+ level = nearest_mipmap_level(tObj, lambda[i]);
+ level = MAX2(level - 1, 0);
+
sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
}
}
@@ -1873,6 +1884,7 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_image **images;
GLfloat newCoord[4];
GLint level = nearest_mipmap_level(tObj, lambda[i]);
+ level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
}
@@ -1891,6 +1903,7 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx,
const struct gl_texture_image **images;
GLfloat newCoord[4];
GLint level = linear_mipmap_level(tObj, lambda[i]);
+ level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
@@ -1919,6 +1932,7 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx,
const struct gl_texture_image **images;
GLfloat newCoord[4];
GLint level = linear_mipmap_level(tObj, lambda[i]);
+ level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],