How to dynamically set texture/sampler filter modes for textures in .fx files???

How to dynamically set texture/sampler filter modes for textures in .fx files???

Post by Brian Laws » Tue, 18 Jul 2006 10:01:16


Does anyone happen to know how to dynamically change the texture
filtering modes for textures/samplers that are defined in .fx files??

I've tried binding samplers to specific sampler registers with the
following declaration:

sampler2D Foo : register( s0 ) = sampler_state...

and then from the DirectX side of things going:

pDevice->SetSamplerState( 0, LINEAR, POINT, etc. ) --> however this
does not seem to work.

Has anyone had any success/luck at all in getting this to work??
 
 
 

How to dynamically set texture/sampler filter modes for textures in .fx files???

Post by Wessam Bah » Tue, 18 Jul 2006 13:59:39

The you're doing it can work if you do the call after all D3DX BeginPass()
and CommitChanges() calls. However, this is not the right way of doing it.
Just simply bind the sampler state to a variable that you control through
the ID3DXEffect interface as you do with shader constants.

For example:

texture texDecal;
int minFilterVal = 1; // Linear

sampler mySampler = sampler_state
{
texture = (texDecal);
MipFilter = Linear;
MagFilter = Linear;
MinFilter = (minFilterVal);
};

And you don't have to explicitly bind the sampler to a sampler register this
way...

--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts

 
 
 

How to dynamically set texture/sampler filter modes for textures in .fx files???

Post by Brian Laws » Wed, 19 Jul 2006 00:24:38


Wow -- I had no idea this way of doing it worked. Although come to
think of it -- I don't know WHY I never tried that, because I assign
the texture for the sampler that way. Doh!

Feel free to kick me. :)

I'm gonna go give this a shot right now. Thanks for the quick response!
 
 
 

How to dynamically set texture/sampler filter modes for textures in .fx files???

Post by Brian Laws » Wed, 19 Jul 2006 03:03:52


I just wanted to follow up and say that this WORKED. Thanks again for
the prompt reply!