2
\$\begingroup\$

I have simple app that renders some particles and now I am trying to apply the bloom shader from the xna samplers ( http://create.msdn.com/en-US/education/catalog/sample/bloom ) to it, but I am running into this exception:

"XNA Framework HiDef profile requires TextureFilter to be Point when using texture format Vector4."

When the BloomComponent tries to end the sprite batch in the DrawFullscreenQuad method:

        spriteBatch.Begin(0, BlendState.Opaque, SamplerState.PointWrap, null, null, effect);
        spriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White);
        spriteBatch.End(); //<------- Exception thrown here

It seems to be related to the pixel shaders that I am using to animate the particle. In a nutshell, I have a texture2d in vector4 format that holds particle positions, and another one for velocities. Here is a snippet from that area:

        GraphicsDevice.SetRenderTarget(tempRenderTarget);
        animationEffect.CurrentTechnique = animationEffect.Techniques[technique];
        spriteBatch.Begin(SpriteSortMode.Immediate,
                          BlendState.Opaque,
                          SamplerState.PointWrap,
                          DepthStencilState.DepthRead,
                          RasterizerState.CullNone,
                          animationEffect);

        spriteBatch.Draw(randomValues, new Rectangle(0, 0, width, height), Color.White);
        spriteBatch.End();

What I comment out the code that calls the particle animation pixel shaders the bloom component runs fine. Is there some state that I need to reset to make the bloom work?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;

This will set the first SamplerState to PointWrap. Do this before you call your spriteBatch.Begin();.

\$\endgroup\$
4
  • \$\begingroup\$ Sadly, this does not help, I get still the same exception \$\endgroup\$
    – Mr Bell
    Nov 18, 2011 at 15:11
  • \$\begingroup\$ What should each of these states be set to? \$\endgroup\$
    – Mr Bell
    Nov 18, 2011 at 16:28
  • \$\begingroup\$ I checked the states of these before and after the spriteBatch.begin() and with my particle system turned on and off, and they are always the same. DepthStencilState = none, BlendSate = AlphaBlend, and RasterizerState = CullCounterClockwise \$\endgroup\$
    – Mr Bell
    Nov 18, 2011 at 18:48
  • \$\begingroup\$ I set the SamplerStates on element 1 instead of 0 and it works now. Thanks \$\endgroup\$
    – Mr Bell
    Nov 18, 2011 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .