Hi I am setting the sampler states initially then setting them on the fly with keypresses that I know runs but I dont see anything changing. Am I missing something. Can I just call SetSamplerState(...) anytime or do I need to call something after?

    static bool bToggleH = false; 
    static int  iNum     = 0; 
    if(KEY_DOWN(VKY_H)) 
        if (bToggleH) 
        {
            bToggleH = false; // run once

            switch (iNum)
            {
                case 0:
                    g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_POINT");
                    m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); // minification
                    break;
                case 1:
                    g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_LINEAR");
                    m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); // minification
                    break;
                case 2:
                    g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_ANISOTROPIC");
                    m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC); // minification
                    break;
            }
            if (iNum < 2) iNum++; else iNum = 0;
        }

    if(KEY_UP(VKY_H)) if (!bToggleH) bToggleH = true; // only true if keyup

Recommended Answers

All 4 Replies

You are able to change the sampling state any time you wish.

Because you're modifying the filters for textures that are minified (opposite of magnified), you should see the difference of the texture from a distance.

You can try using the same texture of the same size drawn far away from the camera but change the sampler state for each one.

Thanks again... Please have a look at my screen shots. The Cube in the center is a control. While I compare the 3 MAGFILTERS together. MINFILTERS are also here to cpmpare them against each other. Please have a look here Click Here

I only see a tiny weeny differance hardly noticeable really in the minfilters. the magfilters are are the same really.

The difference is very clear when you use small or large textures.

Here is an example of mapping a 4x4 texture onto a square where each side is 1.0 long and the screen width is 640x480. The left square is drawn using nearest-point sampling. The one on the right is drawn using bilinear texture filtering.

The purpose is to show how mapping a very small texture (ie. 4x4) onto a large primitive can affect the outcome. When a texture is magnified, many pixels can be mapped to one texel which can create a chunky appearance. It is best to avoid nearest-point sampling and use bilinear filtering. Bilinear texture filtering will use the weighted average of the 4 closests texels to draw onto the pixel.

http://imageshack.us/photo/my-images/840/texturefilters.jpg/

The left square is exactly what the 4x4 texture looks like with red, green, blue, and white squares in the center.

To see the result of minification, try drawing a large texture onto a small primitive. When I say small I mean on the screen.

For anistropic sampling, it can be used with bilinear filtering to improve the quality of textures. Anisotropy is the result of the primitive being drawn at an angle which can distort the texels of the object.

I recommend reading DirectX documentation provided with the DirectX SDK for more about texture filtering.

Interesting... I noticed nothing with a 4x4 texture at a distance but there was noticable change in the magnification filters close up... such as the NONE and POINT were jagged and LINEAR and ANISOTROPIC were smooth (blurry). There was no effect close up with this when the min filter was set to anisotropic.

these are my observations of a 512x512 texture far away.
This is a Minification comparison.
Most of the time the effects were more prominent upon flat planes (horizontal). But horizontal and XYZ rotated planes also were tested

*************************************************
       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MAG                                    true

                          and

       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MIN    N/A       N/A       N/A         N/A


*************************************************
       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MAG                        true            

                          and

       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MIN    N/A       N/A       Darker      Darker


*************************************************
       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MAG             true

                          and

       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MIN    Blurry   Blurry  Very Blurry   Clear


*************************************************
       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MAG    true

                          and

       NONE  |  POINT  |  LINEAR  |  ANISOTROPIC
MIN    Jagged   Jagged    Blurry       Clear


*************************************************
*************************************************
*************************************************


This is a Magnification comparison with a 128x128 texture or even a 4x4.
Same test with MIN = NONE, POINT or LINEAR
Mag results close up were:
    NONE:           Jagged
    POINT:          Jagged
    LINEAR:         Blurry (smooth)
    ANISOTROPIC:    Blurry (smooth)

I noticed I needed to change my code to include NONE in the filters.
haha that was fun... now I can move on in my learning... thanks d

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.