0

Can anyone please help me how to do .png image blur using DirectX9 (2d graphics feature of d3d) without using the advance 3d features like High Level Shader Language(HLSL), Direct3D Per Pixel Motion blur and Vertex Shader.

Detailed explanation:

I've a row of 6 adjacent .png images(6 Sprite textures) on a surface and then I continuously moving/changing the texture locations in a circular fashion (1->2->3->4->5->6->1->2->3->4->5->6) with varying alpha component for getting the feel of spinning effect (2 dimensional spinning).

Problem:

Even with varying sprite texture alpha values and varying frame per sec(fps) I didn't get the real feel of spinning apart from continuous image change. After so many web search I found the clue that it is possible to get the spinning effect if I apply the blur effect(Gaussian blur / box blur) in .png file on the fly.

But due to 3d support restriction in my target platform I can't use the advance 3d features of direct3d apart from 2d features for getting the spinning effect (kind of motion blur).

I warmly welcome the forum member for their kind help / suggestion / Sample code / directing me to right path for solving this problem.

Sample Code:

void D3DGraphics::DrawSprite(LPDIRECT3DTEXTURE9 &texture,ID3DXSprite* pSprite, DXVECTOR2 Trans_11, int ImgIndex) {

D3DXMATRIX Matrix;
pDevice->Clear( 0,NULL,D3DCLEAR_STENCIL,D3DCOLOR_XRGB(0,0,0),0.0f,0 );

pSprite->Begin(D3DXSPRITE_ALPHABLEND);
D3DXMatrixTransformation2D(&Matrix, NULL, NULL, NULL, NULL, 0, &Trans_11);
pSprite->SetTransform(&Matrix1);

--> Need blur effect before write operation / while loading .png file as texture <---

pSprite->Draw(texture[ImgIndex], NULL, NULL, NULL, 0xFFFFFFFF); 
pSprite->End();

}

SridharKritha
  • 8,481
  • 2
  • 52
  • 43

2 Answers2

1

If cycling through 6 images isn't enough to provide smooth animation, why not cycle through say 12 or 24? If you only have 6 "original artworks" it'd still be easier to generate the intermediate images up front using photoshop/imagemagick type tools and just having your app load load them than trying to do it in DirextX.

timday
  • 24,582
  • 12
  • 83
  • 135
  • Thx for your kind comments - transition from one image to another through intermediate image definitely gives better smoothness but I'm afraid it won't give spin effect without blur effect on top and bottom of the changing images. – SridharKritha Jan 26 '13 at 16:23
0

Here is A Link to C++ Box Blur to one chinese's website blog

hope

sgf
  • 11
  • 2