Jump to content
  • Advertisement
Sign in to follow this  
cjlm007

Problem with BulletHole effect and alpha blend

This topic is 2953 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'm making a simple FPS game, and I got a problem when I try to implement the

bullet hole effect.

My bullet hole texture is from AssultCube, with a gray background(128,128,128).His

code is:
glBlendFunc(GL_DST_COLOR,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1,1,1,1);

It works, the gray background is transparent.

But I use Direct3D,here is my code:
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
The vertex's diffuse color is white(1,1,1).Why my texture's background is dark

gray? I wanna transparent.

In addition, if I delete the line of glColor4f(1,1,1,1) in AssultCube, his

background is dark gray too.

Who can give me a hand? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
You need
g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

About the second part - sorry I've got no idea what glColor4f is, never used OpenGL.

Share this post


Link to post
Share on other sites
sorry it doesn't work.
I try
Device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR);
Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

also it doesn't work...

Share this post


Link to post
Share on other sites
Your texture has no alpha value. Thats why following is not working.

g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

Share this post


Link to post
Share on other sites
How does the effect work, in fact?
Does it render a rectangle with a hole texture on a wall? Or how?

Share this post


Link to post
Share on other sites
thanks for your reference, I solved it!

with a line of:
_SetTextureColorStage(g_pDevice,0,D3DTA_TEXTURE,D3DTOP_ADDSIGNED,D3DTA_CURRENT);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!