Rendering problem (D3D9)

Started by
2 comments, last by sirob 17 years ago
Hi, I have a little game (not so mucha GAME right now hehe) that draws the player moving around, animated. The sprite is drawn from one of 12 parts of one large texture, depending on direction and stance. I have him slanted up, to give a more 3d look (youll see when you see vertex buffer). I have pink as the 'invisible' color that allows you to see whats behind the sprite. Ok, everything looks fine until I have another player drawn on screen. What happens is, when one player 'walks over' anpother pplayer or sprite, if it comes from the left, right or above, it looks fine. However, if spriteA moves UP towards spriteB, spriteA's texture will begin to cover spriteB, even though spriteA has the transparency color. Here's the vertex buffer:

{0.5, spriteAngle, -0.5, 0xffffffff,	0,				0,},
        {-0.5, spriteAngle, -0.5, 0xffffffff,	1.0/X_FRAMES,	0,},
        {0.5, 0, 0.5, 0xffffffff,		0,				1.0/Y_FRAMES,},
        {-0.5, 0, 0.5, 0xffffffff,		1.0/X_FRAMES,	1.0/Y_FRAMES},

where sprite angle is 0.6f I can try to get a SS if you cant understand. Thanks
Advertisement
From what you described, this sounds like a Z-buffering issue. What technique are you using to hide the pink areas of the texture? Are you using Alpha Blending or Alpha Testing? You'd want to either be using the second, or both, for this kind of thing. From the behaviour you're encountering, I'd say you're only using Blending right now.

If you don't quite understand the differences, look up the two terms in the SDK Documentation.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.
Ah! I believe I'm using just blending, do you have a recomdation on what I should use ? (that is, both or just testing)

Thanks
AlphaTesting should be used in any case you want to remove pixels completely using their alpha value. Alpha testing does a "boolean" test per pixel, either it passes or it fails.

Alpha Blending allows for a smooth transition between visible and not visible. If your texture has alpha values between 0 and 255, and you want them to be blended according to alpha, use that.

All in all, Alpha Testing should be used in nearly any alpha-related rendering. Alpha Blending should only be used if intermediate values of alpha are possible, and should be disabled when they are not (blending incurs a small performance penalty when enabled).

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement