Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualgeorge7378

Posted 27 January 2013 - 06:17 AM

Hi everyone,

I'm trying to get my Direct3D scene to render trees using .png images with in-built alpha transparency for the leaves, and I'm running into some problems. At the moment, I have just created a plane with my leaf texture on it before I get into creating an actual tree, and as you can see, it's looking rather weird! I should say that I created the leaf object and applied the texture in Blender, and I then exported it as a .x file. I enabled all the relevant alpha options in my blender material/texture.

[attachment=13377:leaftest.png]

I should also mention that the bright blue colour which shows up where the plane should be transparent is the same colour that I clear my background and z-buffer to when I render the frame (i.e. d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(20, 170, 220), 1.0f, 0);). The only thing I have done to my code to enable the alpha transparency is this:
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);    d3ddev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);    d3ddev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);    d3ddev->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);

So - can anyone see an obvious issue with my method?

Thankyou very much :)

#1george7378

Posted 27 January 2013 - 06:15 AM

Hi everyone,

 

I'm trying to get my Direct3D scene to render trees using .png images with in-built alpha transparency for the leaves, and I'm running into some problems. At the moment, I have just created a plane with my leaf texture on it before I get into creating an actual tree, and as you can see, it's looking rather weird! I should say that I created the leaf object and applied the texture in Blender, and I then exported it as a .x file. I enabled all the relevant alpha options in my blender material/texture.

 

[attachment=13377:leaftest.png]

 

I should also mention that the bright blue colour which shows up where the plane should be transparent is the same colour that I clear my background and z-buffer to when I render the frame (i.e. d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, Sky, 1.0f, 0);). The only thing I have done to my code to enable the alpha transparency is this:

 

    d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    d3ddev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
    d3ddev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
    d3ddev->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);

 

So - can anyone see an obvious issue with my method?

 

Thankyou very much :)


PARTNERS