Archived

This topic is now archived and is closed to further replies.

tag

Is a 3D sprite possible in DirectX?

Recommended Posts

By 3D sprite I mean a picture with a Z buffer so each pixel has it''s own depth. Ideally that would be an offset from a Z position so I can move the picture back and forward by just changing one number. Thanks T.

Share this post


Link to post
Share on other sites
Sure it''s possible. All you have to do is draw a quad, and just like you''d move it in the X and Y, you can move it in the Z. Stuff further away will be overlapped by closer stuff, if you have the ZBuffer on. You can also just sort the sprites yourself from back to front then draw.


--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
Thanks Mark. That was exactly what I was looking for. And it was the reason I was looking for it too, because I wanted explosions to look spherical instead of like billboards.

Trouble is ... it doesn''t run on my video card (a GeForce3). Is there no other way of getting the same effect?

t.

Share this post


Link to post
Share on other sites
I believe that you need ps1.3 or better to write out depth values per-pixel. A GeForce4Ti or Radeon8500 will do the trick. NVidia has a demo somewhere on there site about depth sprites so you can look for that to be sure. ATI''s demo is going to use ps1.4 (since its native to their card, Radeon''s actually have to do some emulation for ps1.3 or less), so for NVidia cards you should definitely find an NVidia demo for it. Try http://developer.nvidia.com/docs/IO/3240/ATT/Cg_Effects_Explained.zip, and look for depth sprites in there.

Share this post


Link to post
Share on other sites
You can access the zbuffer directly although it wouldn''t be as fast as using pixel shaders. Look in the DirectX sdk helpfiles, you can see what values to set and lock the buffer to gain access to that there.

____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won''t engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.

Share this post


Link to post
Share on other sites
Accessing the ZBuffer will actually be downright slow (lock the buffer, write pixels, unlock...that throttles the drawing pipeline while locked), and tricky.

You have to create a lockable ZBuffer (which is D3DFMT_LOCKABLE_D16 or something like that), but those aren''t exactly widely supported by hardware. And they''re usually only 16-bit precision, which doesn''t always cut it anymore in today''s games.

And I could have thought that NVidia had depth sprites working on the GeForce3....I''d suggest checking the NVEffectsBrowser. I''m sure it''s possible (I just haven''t done it myself so I don''t know that for sure).

If you can''t go the pixel shader route, then I''d agree with DrunkenHyena...you''d have to break up the geometry. I highly recommend NOT going the lockable-Z route.


Josh

Share this post


Link to post
Share on other sites
Just to emphasize: I actually never said it would be fast.

____________________________________________________________
Try RealityRift at www.planetrift.com
Feel free to comment, object, laugh at or agree to this. I won''t engage in flaming because of what I have said.
I could be wrong or right but the ideas are mine.

Share this post


Link to post
Share on other sites