Point sprites in DX8

Started by
3 comments, last by Zantac 21 years, 1 month ago
Hello everybody, I''ve been trying to do a nice particle system, and decided I wanted to have animated particles (different textures). This unfortunately resulted in a lot of texture switches. I''m using point sprites, but they seem to be limited to a single texture at a time, and what''s worse, the texture coordinates are generated by the card (or so it seems). What I''m wondering is: is there any way to specify texture coordinates for each point sprite, so that I can cram several different particle images into the same texture, and then perhaps use some sort of a vertex shader program to generate texcoords and select the appropriate rectangle in the texture? Is there perhaps another way to solve the problem? I really don''t want to sort the particles according to what texture they use, and then draw them with several calls, since I want to have a LOT of different textures on the particles ( like >200 ). Cheers, Simon
Advertisement
200 + texture on the particles? ...... or 200+ particles with multi textures?
Sorry I wasn't clear enough I want to have 8000-10000 particles in the system, each particle using just one texture, but they use 200 different textures in the system alltogether(some particles use different "frames" of a fire animation, yet some other use different "frames" of a smoke animation, etc. )

Therefore it would be nice if I could cram all of the frames into a single texture. For example, if each animation frame is 32x32 pixels, then i would be able to cram 16x16=256 frames of animation into a single 512x512 texture (16x32=512). If I cant do this, and instead have to have 200 different textures (one
for each frame of animation) then I would have to:

1. use 200 SetTexture()-calls per frame just for that particle system... yuck!

2. Sort the particles according to which texture they would use, and update a vertex buffer with the information (which would mean that i would have to send 8-10k verts to the card each frame)

This would suck tremendously! (

If i instead could generate texcoords for the particles using a vertexshader, then this would be a breeze. The problem is that i haven't found how to do that in the SDK documentation. The docs state that the texcoords are generated for each point sprite by the card so that it uses the entire texture. What i'm looking for is a way to override/bypass this so that i control what parts of the texture is used for the sprite.

Another method i was thinking of (in case you just can't do that with point sprites) is using a vertex program to convert a vertex stream into screen aligned billboards (then i could control the texturing myself, and presto! problem solved), but i don't know if that's possible either.

Any thoughts?

Thanks,
/Simon



[edited by - zantac on March 16, 2003 5:02:04 PM]
A time comes when D3D point sprites simply won''t do. I''ve created my own particle systems, and I decided not to use point sprites for the exact reason you just pointed out. There''s no (easy) way to mix textures by offsetting texture UV coords.

Like you said, what happens if you want to mix different textures in the same emitter? It''s impractical to sort particles by texture and then draw them. If they''re not depth sorted, they''ll have overlap problems, and they''ll overlap incorrectly ANYWAY if different textures are being used in the same localized area. This would look ugly to say the least.

What I did instead of using point sprites was create a dynamic vertex buffer and a static index buffer. My own routines apply the "billboard" sprite effect (slower than point sprites for sure), but the visual benefits far outweigh the performance hit. This is also the technique used in Unreal for sprite, beam, and ribbon emitters.

Depending on the type of engine you''re dealing with, it''s probably not practical to draw ALL particles in a single pass. Anything outside of the view frustum shouldn''t be drawn. Also, it''s not practical to cram ALL particle textures into a single group. Some may have different size requirements, etc.

Also, DON''T allow mipmapping on grouped particle textures, and NEVER allow texture pixels to exist in a 1-pixel border around each texture "cell". Otherwise, you''ll get terribly ugly bleeding from neighboring texture cells and whatnot.
Thanks, man. It wasn''t the answer I was hoping for, but now I know there''s no way to use point sprites for that and can stop racking my brain Thanks also for the tips on grouping textures.

Cheers,
/Simon

This topic is closed to new replies.

Advertisement