Texture Mask

Started by
3 comments, last by xissburg 18 years, 6 months ago
How do i combine a texture and a texture mask to create an image that has transparent and partially transparent parts to the image?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Advertisement
Hi there EvilKnuckles666,
How are you doing buddy?

The Problem
Blending textures, such as a lightmap and a diffuse texture.

The Solution
Toymaker has an excellent article on texture stage states.

I think this is what you are looking for. He also has an example of using the texture stage states to do what you are looking for.

I hope this helps.
Take care buddy.
thanks, i can use that for my other stuff i needed.
But i was talking about having a regular texture for a sprite, then applying a mask to it. The mask would be in greyscale; the closer to black the color is, the more opaque the end texture will have and the closer to white the color is, the more transparent the end texture will have.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
You really just want to look into using plain alpha channels encoded into your sprite image.

These can be created in almost any paint package.

You then simply set the texture stages to use the image information as the alpha source and your sprite will be more opaque the brighter your alpha channel is and more transparent the darker it is.

I can dig out the states for you if you need them but its pretty self-explanatory.
If you make a .tga 32 bit image with an alpha channel, you can use the info in the alpha channel to generate the transparency. In the code, you'll just need these 3 RenderStates:

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


Hope this helps....cya

.

This topic is closed to new replies.

Advertisement