Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2011-06-15 22:59:22 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-06-15 22:59:22 +0400
commita3e296fc4060ab9aac46a8ec2f18696d6776d653 (patch)
tree30e88b71fe489525c3c6072cd32d0cf0003389af /source/blender/gpu/intern
parent08c155845db4ba8157519f60707fcb156f27fd2b (diff)
Committing patch #25676 Anisotropic filtering in viewport and BGE by me.
This patch adds anisotropic filtering of textures in the viewport and the BGE. The quality of the filtering is adjustable in the user preferences under System. For more information on anisotropic filtering: http://en.wikipedia.org/wiki/Anisotropic_filtering One current limitation of this setup (having the option a user preference) is it makes runtimes more troublesome. Runtimes don't have user preferences set, so for now the blender player defaults to 2x AF. Options will be added later to change this value (probably a command line option).
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 7dfbc52819e..87d25ac850a 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -246,8 +246,9 @@ static struct GPUTextureState {
int domipmap, linearmipmap;
int alphamode;
+ float anisotropic;
MTFace *lasttface;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, NULL};
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL};
/* Mipmap settings */
@@ -292,6 +293,26 @@ static GLenum gpu_get_mipmap_filter(int mag)
}
}
+/* Anisotropic filtering settings */
+void GPU_set_anisotropic(float value)
+{
+ if (GTS.anisotropic != value)
+ {
+ GPU_free_images();
+
+ /* Clamp value to the maximum value the graphics card supports */
+ if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
+ value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
+
+ GTS.anisotropic = value;
+ }
+}
+
+float GPU_get_anisotropic()
+{
+ return GTS.anisotropic;
+}
+
/* Set OpenGL state for an MTFace */
static void gpu_make_repbind(Image *ima)
@@ -559,6 +580,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int
ima->tpageflag |= IMA_MIPMAP_COMPLETE;
}
+ if (GLEW_EXT_texture_filter_anisotropic)
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
/* set to modulate with vertex color */
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);