Jump to content
  • Advertisement

Archived

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

CGI Joe

I *think* I'm going mad.

This topic is 6424 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

Bluddy alpha-blending again. Ok, I want to be able to control the translucency level of a polygon (and it''s texture) by specifying an alpha value in the diffuse colour component in each vertex. I''m halfway there; I can get it to blend smoothly from solid to 50/50. It''s like the alpha stops at 128 or something (it doesn''t :p). When I remove the poly''s texture, I can gain full alpha control with the bare polys. So what difference does the texture make? Texture is 16-Bit (R5G6B5) BackBuffer/Primary is 16-Bit (R5G6B5) Material diffuse shares the Material ambient settings (1,1,1,1) Light (directional) is bright white (255,255,255,255) Here''s a portion of the main loop (I''m still playing so ignore the ton of state changes per cycle :p)

  lpDevice->Clear(0, NULL, D3DCLEAR_TARGET, 
                              D3DCOLOR_XRGB(0,0,0),1.0f,0);

  lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
  lpDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); 
  lpDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);

  lpDevice->BeginScene();

  hr = lpDevice->SetTexture(0,TextureList[0]);
   
    SetupLights();
    SetupMatrices();
  lpDevice->SetStreamSource(0,lpVB,sizeof(CUSTOM_VERTEX));
  lpDevice->SetVertexShader(D3DFVF_CUSTOM_VERTEX);
  
  lpDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 
                                               sm_map->numpolys);
  lpDevice->EndScene();
  lpDevice->Present(NULL, NULL, NULL, NULL);

 
Anyone know anything I should know? I''d appreciate any help as this is *really* slowing me down! Cheers,

Share this post


Link to post
Share on other sites
Advertisement
Sounds like you may be modulating the alpha value between the Vertex Alpha and the Texture Alpha.

Now if a texture has no alpha(as yours doesnt) i 'THINK' d3d treats it as having an alpha value of 255 so this would mean that even with Vertex Alpha set to zero it would still only be 50% transparent.

Try setting your texture stage like this before you render

lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);

lpDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);

Hope that helps


Edited by - gazza on January 11, 2001 10:58:21 PM

Share this post


Link to post
Share on other sites
Gazza,

Oh God. Oh God.

YOU ARE A GOD.

Thank you so much! That was driving me nuts! I can't thank you enough - now I can get on with what I was doing about 2 weeks ago. Thanks again! =)



Edited by - CGI Joe on January 12, 2001 3:06:11 AM

Share this post


Link to post
Share on other sites
WOW ! Guess it worked

Actually thats what I keep telling my girlfriend but she''s having none of it

Anyway, glad I could help

Gary Simmons
www.mr-gamemaker.com

Share this post


Link to post
Share on other sites

  • 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!