zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
114 stars 22 forks source link

Anisotropic filter missing #110

Open m-7761 opened 4 years ago

m-7761 commented 4 years ago

I just noticed there's no anisotropic filter. I added the following to Model::loadTextures and also had to add a m_validContext member to cover the context-free mode using the OpenGL texture inside the Material object.

    int anisof = 0;
    glGetIntegerv(0x84FF,&anisof); //GL_TEXTURE_MAX_ANISOTROPY_EXT
    //TODO: Add to preferences.
    anisof = std::min(16,anisof);

...

glTexParameteri(GL_TEXTURE_2D,0x84FE,anisof); //GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT

I'm sitting on a significant upgrade if it can be integrated, this will be included.

m-7761 commented 4 years ago

Off-topic/related:

    //glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR); //2020
    glLightModeli(0x81F8,0x81FA); //2020

This can be added to initializeGL to get specular highlights. This is typically used by legacy OpenGL viewers since specular with the regular lighting model is not really anything like a specular highlights. The one drawback to this is it changes the appearance of the material pretty dramatically, so it would alter old MM3D files. It could be enabled selectively if that's a problem.

Also the glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,false); lines aren't likely required since that's the default and the difference from what I can gather is negligible. I think "true" should be used if anything probably... I think it's for VR maybe. I think it enables the equivalence of (per-vertex) range-fog (as opposed to pseudo depth-fog) but for specular highlight calcuation.