Can I use PixelShaders with Sprites

Hello,
First, We can I usepixel shaders withsprites?
Second, Is Spritesfast enough to not drawing with a conventional way(Holding the vertices in vertex buffer and then apply a texture to them and use the pixel shader as regular)?
I want to know which one isfaster?
Thanks,
Mustafa ELBanna

[398 byte] By [MustafaELBanna] at [2008-2-13]
# 1
Point sprites are fast, but very limited - you can't do a lot of things with them. And they're not usually significantly faster than normal triangles. I would use the standard method to start with. Generate your own vertices and render indexed triangles. It's far simpler to do.
TomForsyth at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2
Sprites essentially represent a way to work with vertices in a vertex buffer with an interface that resembles the traditional idea of a "sprite".

They will not be faster (at least not significantly faster) than correct vertex-buffer usage.

In terms of pixel shaders, I think it really comes down to how you want your render-pass code to be organized. I don't see why you couldn't, for example, draw Sprites inside an Effect begin/end block, but I'm not 100% sure you can. I'll reply again soon with confirmation.

mattpic at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3
Sprites are a fundamentally different primitive type to triangles, and use different hardware. That is the reason there are restrictions on their size, orientations, interpolants, etc. They are faster than triangles in some limited circumstances, for example if you are drawing tens of thousands of small ones and your shader is fairly simple.
That is also why various bits of hardware have various odd restrictions on how and where you can use them. I would NOT recommend using them inside the DXEffect system, because it makes it hard to work around some of the oddness (especially on PS1.x hardware).
In conclusion, for most practical purposes, they're just not worth the hassle. They're only a small speed boost at best, only faster in certain specialised rendering circumstances, they have arbitrary limits on the things they can do, and they're a real pain to use.
TomForsyth at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4
Just to check, was the question about point sprites or d3dx sprites?
SteveClibbery at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 5

Hello,
I really talking about D3DX sprites?
Thanks,
Mustafa ELBanna

MustafaELBanna at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 6
Ah - totally forgot about D3DX sprites. I was talking about point sprites, and looks like Matt was talking about D3DX sprites. Hence the confusion.
TomForsyth at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 7

MustafaELBanna wrote:
First, We can I use pixel shaders with sprites?

I haven't tried it myself, but I don't see any reason why you couldn't.
MustafaELBanna wrote:
Second, Is Sprites fast enough to not drawing with a conventional way (Holding the vertices in vertex buffer and then apply a texture to them and use the pixel shader as regular)? I want to know which one is faster?

Using ID3DXSprite should be just as fast as drawing the quads yourself.

RossRidge at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 8
Sorry this took so long - if you want to use Effects, I recommend you build the vertex buffer yourself. You could draw D3DX sprites within an Effect block, but the vertices might not come as you would expect them to. It would certainly be easier to just deal with the vertex data yourself.
mattpic at 2007-9-9 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...