Sign in to follow this  

How do I enable bilinear filtering in DirectX?

This topic is 3857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I enable bilinear filtering in DirectX? Is it enabled by default? What I'm trying to do is render a large scene to a small texture and then stretch it back over the entire scene again... (eg. a simple bloom effect)

Share this post


Link to post
Share on other sites
The default filter mode is point filtering. Assuming you're using the fixed function pipeline:
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

If you're using shaders, I've no idea.

EDIT: This actually shows up if you type "bilinear" into the SDK docs "Search" tab...

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
The default filter mode is point filtering.


Don’t trust the default. Many drivers use better filters when you don't set them at all.

Quote:
Original post by Evil Steve
Assuming you're using the fixed function pipeline:
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);


For bilinear you should add SetSamplerState (D3DSAMP_MIPFILTER, D3DTEXF_POINT).
SetSamplerState (D3DSAMP_MIPFILTER, D3DTEXF_LINEAR) will give you trilinear.

Quote:
Original post by Evil Steve
If you're using shaders, I've no idea.


It is the same. Shaders respect the sampler states too.

Share this post


Link to post
Share on other sites
When using shader in the FX system, you often set the sampler states in the FX file itself.
texture diffuseTexture : DiffuseTexture;

sampler DiffuseTextureSampler = sampler_state
{
texture = <diffuseTexture>;
AddressU = WRAP;
AddressV = WRAP;
AddressW = WRAP;
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};

Omitting states will likely use whatever was set in code, which can be useful for setting the states globally.

Share this post


Link to post
Share on other sites

This topic is 3857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this