Point Sprites & Shaders

Started by
6 comments, last by Capoeirista 17 years, 1 month ago
Hey people, I'm having some issues with the DirectX point structure at the moment and was wondering if any of you could lend a hand. My problem is this - I'm writing a particle system editor and am using the an array of points to render the particles; I want to keep it this way as I'm rendering upwards of 6000 particles at a time and using billboarded quads simply isn't fast enough. Since I want the particles to be textured I have D3DRS_POINTSPRITEENABLE set to true. This hasn't been a problem up until now. I want to do most of the effects and lighting calculations for the particle system in the vertex and pixel shaders, but the problem is that setting D3DRS_POINTSPRITEENABLE to TRUE means that after the vertex shader has done it's thing, all of the texture stages are wiped and I only get the texture coordinates for the selected texture coming through to the pixel shader. This means that in the pixel shader I can't get access to normals or any of the lighting calculations performed in the vertex shader. I've tried specifying specific stages in both the vertex format declaration, the structures I'm using to pass output from the vertex shader to the pixel shader and specificially disabling texture stages I want to use in the shaders; nothing seems to work though. I know i can use the COLOR0 and COLOR1 outputs, but COLOR0 is usually taken up with the colour of the vertex and I often need to pass more than two parameters to the pixel shader. Do any of you have any idea how to use point sprites with texture coordinate generation and still be able to use the texture stages in shaders? Your help would be greatly appreciated!
Advertisement
Hi!

Maybe you can find som useful information from these links, i think the particle demos are using point-sprites.

http://www.moon-labs.com/

http://www.wordware.com/files/dx9c/
_____________________Lecturer at Blekinge Institute of Technology
Couldn't seem to get around the point sprite texture coordinate generation wiping all of the texture stages unfortunately.

Got around the problem by rendering the particles as a triangle list, using six vertices for each particle.

This works reasonably well if you set all six vertices to the same position and then offset them in the vertex shader using the texture coordinates and particle size.
The NORMAL semantic marked values shouldn't get reassigned new values when using PointSprites. I'm not too sure what you mean by "Texture Stages getting wiped out", but I assume you mean that the texcoords get overwritten.

As for triangle lists, if you're drawing quads, use Indexed Triangle Lists, they'll give you a nice speed gain.
Sirob Yes.» - status: Work-O-Rama.
Quote:
The NORMAL semantic marked values shouldn't get reassigned new values when using PointSprites. I'm not too sure what you mean by "Texture Stages getting wiped out", but I assume you mean that the texcoords get overwritten.


Yeah I didn't think that normals would be wiped, but I couldn't compile any of the shaders when I tried to pass a normal in to the pixel shader? Should pixel shaders be able to accept normals as aguments?

By texture stages I mean TEXCOORD0-8, I think they're called stages in good old DirectX... but I've been wrong before :)

Quote:
As for triangle lists, if you're drawing quads, use Indexed Triangle Lists, they'll give you a nice speed gain.


I'm definitly drawing quads and using an indexed triangle list was going to be my next step. I guess it means I wouldn't have to double up vertex declarations.
Quote:Original post by Capoeirista
By texture stages I mean TEXCOORD0-8, I think they're called stages in good old DirectX... but I've been wrong before :)


TEXCOORDs are sets of texture coordinates in the vertex data.
Texture stages (texture stage states, SetTextureStageState) are stages of the fixed-functionality pipeline's texture/shading cascade. The stage states involve controlling the sources and outputs of various stages as well as the actual blending,etc. operations performed in those stages.

Quote:Original post by Anonymous Poster
TEXCOORDs are sets of texture coordinates in the vertex data.
Texture stages (texture stage states, SetTextureStageState) are stages of the fixed-functionality pipeline's texture/shading cascade. The stage states involve controlling the sources and outputs of various stages as well as the actual blending,etc. operations performed in those stages.

Cheers!
Quote:
As for triangle lists, if you're drawing quads, use Indexed Triangle Lists, they'll give you a nice speed gain.

That worked really well, using an indexed triangle list and doing all of the billboarding in the shader means that there's hardly any difference performance wise over using point sprites.

This topic is closed to new replies.

Advertisement