Effects in 2D

Started by
3 comments, last by mateo 18 years, 1 month ago
Hi, I'm wondering about how to implement effects such as blur in a 2D game using textured quads. I've no idea where to start really, I think it might be something to do with texture shaders but I'm not sure. Can anyone offer any help? Thanks!
Construct (Free open-source game creator)
Advertisement
This may help
Thanks for the article. However I should probably elaborate, I want to be able to perform hardware-accelerated effects such as gaussian blur. Any tips or hints about how to go about coding this in DX9 would be greatly appreciated (that article didn't really give any code).
Construct (Free open-source game creator)
You definitely need to be looking into pixel shaders. Depending on your hardware restrictions you'd probably want to be using ps_2_0 as a minimum - preferably ps_3_0...

I'd recommend you check out the PostProcess SDK sample. It's applied to a 3D scene/model, but the basic principles and implementation would be the same for 2D-based...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

You'll have to learn how to setup direct3d and load a texture into a texture object (d3dx is very nice for this!), after you do that then its just a matter of setting the right render-states.
Here is a simple example of setting the min mag filters for a texture:
d3d9device -> SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR)
d3d9device -> D3DSetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR)
This removes the jaggies from the texture when stretched small or large.
The directx SDK will tell you MUCH more you need to know about filters.
You can also try the D3DXSprite interface, but I don't have much experience with this.

This topic is closed to new replies.

Advertisement