How to set a transparent color to a plain?

Started by
10 comments, last by 3dZmaster 20 years, 5 months ago
I have a plain which has a texture mapped in it. How can I add some RGB value to be transparent? thx
Woe to you, oh earth, and sea, for the devil sends the best with wrath, because he knows the time is short. Let him who hath understranding reckon the number of the beast, for it is a human number. Its number is 10011101101010110100110100101010101000101110100110100101010010100101101010101011...
Advertisement
quote:
How can I add some RGB value to be transparent?


The RGB values do not make your object transparent; you need to modify the alpha values. Based on your other post; I would recommend that you start with some tutorials. Try the following site:

http://www.drunkenhyena.com/docs/d3d_tutorial.phtml#Lesson8



_______________________________________
Understanding is a three edged sword...
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com
No, no, no. I dont mean to use Aplha Blending. It makes the whole object transparent. But I''m making a 2d game using plains. I just want to make lets say black parts of the textured plain to be FULLY transparent. I know this is possible. Anyone?

thx
Woe to you, oh earth, and sea, for the devil sends the best with wrath, because he knows the time is short. Let him who hath understranding reckon the number of the beast, for it is a human number. Its number is 10011101101010110100110100101010101000101110100110100101010010100101101010101011...
quote:
I have a plain which has a texture mapped in it. How can I add some RGB value to be transparent?


quote:
No, no, no. I dont mean to use Aplha Blending. It makes the whole object transparent. But I'm making a 2d game using plains. I just want to make lets say black parts of the textured plain to be FULLY transparent. I know this is possible. Anyone?


Strange that it wasn’t perfectly clear to me what you were looking to do from your original post. You can make a single color fully transparent using a Color Key or you can use Alpha Testing to make a range of alpha values fully transparent.

There are tutotials for both at the site I recommended:

http://www.drunkenhyena.com/docs/d3d_tutorial.phtml#DHColourKey
http://www.drunkenhyena.com/docs/d3d_tutorial.phtml#DHAlphaChannel

PS: What is a “plain”? I am assuming that you are talking about a textured Quad?


_______________________________________
Understanding is a three edged sword...


[edited by - Sean Doherty on November 8, 2003 8:58:05 AM]
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com
quote:Original post by Sean Doherty
quote:
I have a plain which has a texture mapped in it. How can I add some RGB value to be transparent?


quote:
No, no, no. I dont mean to use Aplha Blending. It makes the whole object transparent. But I''m making a 2d game using plains. I just want to make lets say black parts of the textured plain to be FULLY transparent. I know this is possible. Anyone?


Strange that it wasn’t perfectly clear to me what you were looking to do. Alpha Testing will do what you want.

PS: What is a “plain”? I am assuming that you are talking about a textured Quad?

I think as in a large area. Like a dessert. Or the Toendra plains (spelling).

Creator of: Science Fiction Career
Percent finnished: 0.1%

Site: comming soon
Forum: comming soon
quote:
I think as in a large area. Like a dessert. Or the Toendra plains (spelling).


I am pretty sure that you can''t make either of these areas transparent? Maybe if you try blinking you eyes really fast!
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com
OH sorry. I'm used to use that expression. Yeah quad is what I mean.

EDIT: Few Typos

[edited by - 3dZmaster on November 8, 2003 9:33:53 AM]
Woe to you, oh earth, and sea, for the devil sends the best with wrath, because he knows the time is short. Let him who hath understranding reckon the number of the beast, for it is a human number. Its number is 10011101101010110100110100101010101000101110100110100101010010100101101010101011...
Damn... Havent got it working yet. I''m trying to learn from the tutorials... :D
Woe to you, oh earth, and sea, for the devil sends the best with wrath, because he knows the time is short. Let him who hath understranding reckon the number of the beast, for it is a human number. Its number is 10011101101010110100110100101010101000101110100110100101010010100101101010101011...
I think by "plain" he means "plane"
Ok... I havent got it working yet.

This is what I''m doing:

InitDeviceObjects()
(not the full code of the function, just what I have added related to the transparency thingy)

	if( FAILED (D3DXCreateTextureFromFileEx(m_pd3dDevice, "main.bmp", D3DX_DEFAULT,D3DX_DEFAULT, 1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,0xFF000000,NULL,NULL,&m_pCharacter) ) ) 




RestoreDeviceObjects()
(not the full code of the function, just what I have added related to the transparency thingy)


  m_pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);   //D3DTSS_COLORARG1 is set to D3DTA_TEXTURE which means that colour1 is   //entirely taken from the texture and nothing else.   m_pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);   //Similarly to the COLOR TextureStageStates, the D3DTOP_SELECTARG1   //says to take the result from arguement 1. We set D3DTSS_ALPHAARG1   //to D3DTA_TEXTURE, which makes the alpha value for each pixel comes   //from the alpha component of the texture pixel (texel).    m_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);    m_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);   //The next 2 RenderStates determine how the blending is done.   //The source is our object, destination is the drawing surface.   //SRCBLEND specifies that the final colour should be 50% (because   //that''s what we set our souce alpha to) from our source and 50%   //(INVSRCALPHA, 100%-SRCALPHA(50% in this case))    m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);   m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);   //This enables Alpha Blending    m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);        m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); 



Thats all I think. In the rendering part I got nothing related to this transparency thingy. Everything works but black isnt transparent...

Woe to you, oh earth, and sea, for the devil sends the best with wrath, because he knows the time is short. Let him who hath understranding reckon the number of the beast, for it is a human number. Its number is 10011101101010110100110100101010101000101110100110100101010010100101101010101011...

This topic is closed to new replies.

Advertisement