Add anisotropic filtering to GLES2 backend
Move definition of rendering/quality/filters/anisotropic_filter_level to servers/visual_server.cpp, since both GLES2 and GLES3 now use it rasterizer_storage_gles3.cpp: Remove a spurious variable write (the value gets overwritten soon after)
This commit is contained in:
parent
0b6dd929c6
commit
09a156ea15
5 changed files with 35 additions and 4 deletions
|
@ -79,6 +79,9 @@ GLuint RasterizerStorageGLES2::system_fbo = 0;
|
|||
|
||||
#define _EXT_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
|
||||
|
||||
#define _GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#define _GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
|
||||
#define _RED_OES 0x1903
|
||||
|
||||
#define _DEPTH_COMPONENT24_OES 0x81A6
|
||||
|
@ -749,6 +752,16 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
|
|||
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
if (config.use_anisotropic_filter) {
|
||||
|
||||
if (texture->flags & VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) {
|
||||
|
||||
glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, config.anisotropic_level);
|
||||
} else {
|
||||
glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int mipmaps = ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
|
||||
|
||||
int w = img->get_width();
|
||||
|
@ -957,6 +970,16 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
|
|||
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
if (config.use_anisotropic_filter) {
|
||||
|
||||
if (texture->flags & VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) {
|
||||
|
||||
glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, config.anisotropic_level);
|
||||
} else {
|
||||
glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) {
|
||||
if (!had_mipmaps && texture->mipmaps == 1) {
|
||||
glGenerateMipmap(texture->target);
|
||||
|
@ -6069,6 +6092,13 @@ void RasterizerStorageGLES2::initialize() {
|
|||
config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc") || config.extensions.has("GL_ARB_texture_compression_rgtc") || config.extensions.has("EXT_texture_compression_rgtc");
|
||||
config.bptc_supported = config.extensions.has("GL_ARB_texture_compression_bptc") || config.extensions.has("EXT_texture_compression_bptc");
|
||||
|
||||
config.anisotropic_level = 1.0;
|
||||
config.use_anisotropic_filter = config.extensions.has("GL_EXT_texture_filter_anisotropic");
|
||||
if (config.use_anisotropic_filter) {
|
||||
glGetFloatv(_GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &config.anisotropic_level);
|
||||
config.anisotropic_level = MIN(int(ProjectSettings::get_singleton()->get("rendering/quality/filters/anisotropic_filter_level")), config.anisotropic_level);
|
||||
}
|
||||
|
||||
//determine formats for depth textures (or renderbuffers)
|
||||
if (config.support_depth_texture) {
|
||||
// Will use texture for depth
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
bool shrink_textures_x2;
|
||||
bool use_fast_texture_filter;
|
||||
bool use_anisotropic_filter;
|
||||
bool use_skeleton_software;
|
||||
bool use_lightmap_filter_bicubic;
|
||||
|
||||
|
@ -82,6 +83,8 @@ public:
|
|||
bool use_rgba_2d_shadows;
|
||||
bool use_rgba_3d_shadows;
|
||||
|
||||
float anisotropic_level;
|
||||
|
||||
bool support_32_bits_indices;
|
||||
bool support_write_depth;
|
||||
bool support_half_float_vertices;
|
||||
|
|
|
@ -408,9 +408,6 @@ void RasterizerGLES3::make_current() {
|
|||
}
|
||||
|
||||
void RasterizerGLES3::register_config() {
|
||||
|
||||
GLOBAL_DEF("rendering/quality/filters/anisotropic_filter_level", 4);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/anisotropic_filter_level", PropertyInfo(Variant::INT, "rendering/quality/filters/anisotropic_filter_level", PROPERTY_HINT_RANGE, "1,16,1"));
|
||||
}
|
||||
|
||||
// returns NULL if no error, or an error string
|
||||
|
|
|
@ -8355,7 +8355,6 @@ void RasterizerStorageGLES3::initialize() {
|
|||
|
||||
config.shrink_textures_x2 = false;
|
||||
config.use_fast_texture_filter = int(ProjectSettings::get_singleton()->get("rendering/quality/filters/use_nearest_mipmap_filter"));
|
||||
config.use_anisotropic_filter = config.extensions.has("rendering/quality/filters/anisotropic_filter_level");
|
||||
|
||||
config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture");
|
||||
config.latc_supported = config.extensions.has("GL_EXT_texture_compression_latc");
|
||||
|
|
|
@ -2437,6 +2437,8 @@ VisualServer::VisualServer() {
|
|||
GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
|
||||
GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
|
||||
|
||||
GLOBAL_DEF("rendering/quality/filters/anisotropic_filter_level", 4);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/anisotropic_filter_level", PropertyInfo(Variant::INT, "rendering/quality/filters/anisotropic_filter_level", PROPERTY_HINT_RANGE, "1,16,1"));
|
||||
GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/skinning/software_skinning_fallback", true);
|
||||
|
|
Loading…
Reference in a new issue