Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [GDK] - Anisotropic Filtering Function (in DarkGDK, no DLLs or hacks)

Author
Message
The Tall Man
10
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 8th Dec 2013 22:34 Edited at: 8th Dec 2013 22:43
I've seen lots of messages in these forums about anisotropic filtering, and how can you do it in DarkGDK?? People saying it didn't work or one who offered a DBPro .DLL, but with no instructions on using it in DarkGDK. Well it's quite possible in DarkGDK without such a .DLL, using a couple undocumented (but available) DarkGDK functions that provide access to lower-level data.

First of all, there already is an undocumented function available that does it:



But it doesn't give you much control. Using that open-source .DLL as a starting point, I wrote another function that provides more control, all within DarkGDK (no third-party stuff or hacks of source code). You can choose the anistropy level yourself (or choose the max supported by your video board). And you can choose which filters you'd like for mipmap selection, minification, and magnification separately.

Such filtering works at an object's texture level rather that a universal environmental level. So I've written a function to apply the filter too all objects up to and including the highest object passed in. I commented within it so you can follow along and easily make any modifications you wish.

Here's the function's prototype:


Here is a call to this function with everything set to match the defaults:


Here is a recommended call to this function to enable anisotropic filtering at your card's maximum supported level:


Since anisotropic filtering is heavier on your card's resources than linear, I kept the magnification filter set to linear, but you can do whatever you want. And anisotropic filtering is undefined on mipmap selection.

And here is the function itself:

The constants are defined in d3d9types.h.

s_i
14
Years of Service
User Offline
Joined: 23rd May 2009
Location: Russia
Posted: 14th Jan 2014 23:08
I tested, it works.
I used a scene with objects that have textures 512x512 and 2048x2048. I see a real difference between D3DTEXF_LINEAR and D3DTEXF_ANISOTROPIC in texture sharpness, FPS decreases only from 463 to 452. Good result for good videocard "NVidia GeForce 660".

But I do not see any difference between anisotropy=2 and anisotropy=4,8,16. No difference in texture sharpness, no difference in FPS. Absolutely. Why?

Login to post a reply

Server time is: 2024-03-28 09:26:22
Your offset time is: 2024-03-28 09:26:22