ID3DXSprite - Suggestion for my engine

Started by
4 comments, last by Jonas B 18 years ago
Hey guys, long time no talk. Anyway, my engine is currently using ID3DXSprite class and working pretty well. My engine is 2D (using 3D). However, I want real lighting. Which is I understand correctly, I can't really do with a quad because there are only two tris. So, I am assuming I would have to use a real mesh/3D object. Here is what I am thinking. For those that have a really fast card, have a mode where everything (including the tiles) are made up of a lot of triangles. Have dynamic lighting, etc. For those that have slower cards, stick to the textured quads of ID3DXSprite. Assuming that plan is solid, I am now in trouble because I've only worked with ID3DXSprite class which as you know, makes it pretty easy to get 2D sprites. And while I am on it, I am also assuming that a "real 3d" engine would allow me things like fog (which now I fake with 2d sprites), full screen rotation/scaling, etc. Oh, I am using C++ and un-managed code and DX9. Any suggestions of where to start or some good tuts would be helpful. I've googled but seem to only find DX8 stuff or stuff for C#. Thanks! cbmeeks
Advertisement
Sorry, I mean to submit this post earlier in the day, but just totally forgot about it here in the tab ;)

Just adding triangles doesn't give you sufficient data to light the scene - specifically, you need to have the normals. Just tesselating the quads doesn't really give you anything.

Have you tried lightmapping? This can be a good way to bake in realistic lighting into your 2D scene.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Depending on your minimum target platform, per-pixel lighting might be an alternative.
Thanks guys.

I have a lot to learn in the 3D world...no, I haven't tried lightmapping but I will look into that.

Basically, I want the ability for a 2d sprite to walk near a light source (like a flame) and gradually get brighter the closer he gets and change hues. Maybe I could fake this some how.

For example, imagine a character walking towards a read lazer. The closer he gets, the brighter (and redder) he gets. As he leaves, the opposite is true.

That would be good enough lighting for me. I like the idea, though, of per-pixel lighting but is that even possible with the ID3DXSprite class? Aren't the video card requirements pretty hefty for that?

Thanks!

cbmeeks
For any shader work with quads, you need your own quad engine I am afraid. ID3DXSprite uses FFP, you can manipulate that if you know your way around in renderstatyes really well. Well, all you can do with the interface is to modulate the colors of the sprite on the whole. If you want godd lighing, you need the per-pixel one, yeah.
Sadly Direct3D for PC does not support the quad primitive type but still you can write a good quad engine with triangle lists, and still draw thousands of quads in one draw call.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Are you sure no shaders are possible with ID3DXSprite? I've seen several people saying it's not pretty, but doable.

That aside, I also recommend creating your own sprite system. Doing what ID3DXSprite does isn't difficult, and you have a lot more flexibility.

My Endogine project ( http://www.codeproject.com/csharp/endogine.asp ) might be of some help if you want to go custom.

This topic is closed to new replies.

Advertisement