I *think* I'm going mad.

Started by
3 comments, last by CGI Joe 23 years, 3 months ago
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,
"You say I''m a bitch like it''s a *bad* thing..."[email=alanetcetc@hotmail.com]Mail[/email] Site
Advertisement
Try making the Backbuffer/Primary buffer 24 or 32 bit, it may help .


http://www.gdarchive.net/druidgames/
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
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
"You say I''m a bitch like it''s a *bad* thing..."[email=alanetcetc@hotmail.com]Mail[/email] Site
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

This topic is closed to new replies.

Advertisement