Add centralized anisotropic filtering, fog, and Blinn-Phong specular to all renderers

Anisotropic filtering now queries GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT once
and applies via a single applyAnisotropicFiltering() utility, replacing
hardcoded calls across all renderers. Fog (sky horizon color, 100-600
range) and Blinn-Phong specular highlights are added to WMO, M2, and
character shaders for visual parity with terrain. Shadow sampling
plumbing (sampler2DShadow with 3x3 PCF) is wired into all three shaders
gated by uShadowEnabled, ready for a future shadow map pass.
This commit is contained in:
Kelsi 2026-02-04 15:05:46 -08:00
parent c9adcd3d96
commit aeccddddeb
10 changed files with 280 additions and 8 deletions

View file

@ -33,6 +33,7 @@ bool Texture::loadFromMemory(const unsigned char* data, int w, int h, int channe
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D);
applyAnisotropicFiltering();
glBindTexture(GL_TEXTURE_2D, 0);
return true;
@ -47,5 +48,22 @@ void Texture::unbind() const {
glBindTexture(GL_TEXTURE_2D, 0);
}
void applyAnisotropicFiltering() {
static float maxAniso = -1.0f;
if (maxAniso < 0.0f) {
if (GLEW_EXT_texture_filter_anisotropic) {
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAniso);
if (maxAniso < 1.0f) maxAniso = 1.0f;
} else {
maxAniso = 0.0f; // Extension not available
}
}
if (maxAniso > 0.0f) {
float desired = 16.0f;
float clamped = (desired < maxAniso) ? desired : maxAniso;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, clamped);
}
}
} // namespace rendering
} // namespace wowee