Sign in to follow this  

Help with sprites2...

This topic is 4381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got my sprite to transform correctly, but I'm having trouble getting the alpha to blend properly. I've got a proper texture that has transparency. I set color to white on the draw method for the sprite. My other problem is that I set the sprite to 0,0,0 and it looks great when I spin my view around and everything. But when I set SpriteFlags.Billboard on the Sprite.Begin method the sprite completely dissapears. Frustrated with sprites, Devin

Share this post


Link to post
Share on other sites
I'm guessing that you're using C#, but the C++ API is probably similar, so:

For alphablending, have you passed the C# equivalent of D3DXSPRITE_ALPHABLEND to Sprite.Begin()?

For billboarding, have you called the C# equivalent of ID3DXSprite::SetWorldViewLH or ID3DXSprite::SetWorldViewRH first before rendering?

Share this post


Link to post
Share on other sites
OK, I'm about to go crazy. I can't for the life of me figure out what's wrong with the alpha. I've checked the texture and it's good. I've checked all the settings and I see nothing wrong there. Is there something with sprites that I'm missing? My other draw funcs in my render loop draw with alpha blending, it's just the sprite that wont go alpha!!!

Share this post


Link to post
Share on other sites
Here's what I have set for render states:


[source lang=c#]     
this.device.RenderState.SourceBlend = Blend.SourceAlpha; //set the source to be the source's alpha
this.device.RenderState.DestinationBlend = Blend.InvSourceAlpha; //set the destination to be the inverse of the source's alpha
this.device.RenderState.AlphaBlendEnable = true; //enable this.texture = TextureLoader.FromFile(device, "tex.bmp");




and here's what I have set to render the sprite:

[source lang=c#]
public void Draw()
{
this.surfacesprite.sprite.SetWorldViewLH(this.device.Transform.World, this.device.Transform.View);
this.surfacesprite.sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.ObjectSpace | SpriteFlags.Billboard | SpriteFlags.SortDepthBackToFront);
foreach (Vector3 pos in this.SpritePositions)
this.surfacesprite.DrawModulated(pos, 45f);
this.surfacesprite.sprite.End();
}

public void DrawModulated(Vector3 position, float angle)
{
if ((CurrentTexture + 1) == NumberOfTextures)
CurrentTexture = 0;
else CurrentTexture += 1;
SurfaceTexture tex = surfacetextures[CurrentTexture];
this.sprite.Draw(tex.texture, tex.center, position, Color.White.ToArgb());

}


Share this post


Link to post
Share on other sites
The sdk docs for alphablend arg says this:

Enables alpha blending with RenderStateManager.AlphaTestEnable set to true (for nonzero alpha). SourceAlpha is the source blend state, and InvSourceAlpha is the destination blend state in calls to RenderStateManager. The Font class requires this flag to be set when drawing text.

Share this post


Link to post
Share on other sites

This topic is 4381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this