Jump to content
  • Advertisement
Sign in to follow this  
ThreeDParadox

alpha blending problem

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

Im having a problem with my particle system. I have created a smoke system with a tga file texture. I need to use the alpha channel from this texture, but i also need to use the alpha channel of the material so i can alpha out the entire billboard as it gets older. Can anyone shed some light on this? I can use one or the other, but i cant get it to let me use both.

Share this post


Link to post
Share on other sites
Advertisement
Could you possibly average the two? Or, alternatively, could you do something like rather than reducing alpha as the billboard ages, have an age value that describes how far from the original alpha of a pixel that pixel should be, example:

2 pixels (alpha values in the middle):
________________________
| 255 | 128 | or | 1.0 | 0.5 |

So then you have an 'age' value so:

for each pixel on billboard

currentAlpha = originalAlpha * (1 - age) //where age starts at 0 and moves towards 1 and originalAlpha is read from texture file


So, when rendered at an age of 0.5, these pixels look like:
_______________________
| 128 | 64 | or | 0.5 | .25 |

And at age 1 (entirely dead), all pixels are transparent so you don't need to render.

I'm not sure of performance issues with this method or if it's even possible with DirectX and billboards (have no experience with either except through the flowered facade of XNA :), but that's another way of doing it.

Share this post


Link to post
Share on other sites
Simply multiply/modulate the alphas. In a shader just multiply them.

In fixed pipeline, you're likely setting up an alpha stage as: op=D3DTOP_SELECTARG1, arg1=D3DTA_TEXTURE
or
op=D3DTOP_SELECTARG1, arg1=D3DTA_DIFFUSE.

Instead setup the alpha stage as:
op=D3DTOP_MODULATE with arg1=D3DTA_TEXTURE and arg2=D3DTA_DIFFUSE.

Share this post


Link to post
Share on other sites
Quote:
Original post by ThreeDParadox
Im having a problem with my particle system. I have created a smoke system with a tga file texture. I need to use the alpha channel from this texture, but i also need to use the alpha channel of the material so i can alpha out the entire billboard as it gets older. Can anyone shed some light on this? I can use one or the other, but i cant get it to let me use both.


Some standard questions apply:
- C++ or managed code?
- fixed-function or shader?

For fixed-function, it sounds like you need to brush up on the texture stages and the associated states. Whether its a shader or a FFP configuration, I always start by writing down the math of what I want to achieve. If you can't write the math, then you don't know what you want and you should figure that out first before you try to code it.

After you have the math, then you encapsulate that in either a shader -- where you tend to write out the math directly -- or in a fixed-function texture stage configuration. The texture stages are complex and have to be correctly configured or you'll never understand what's going on. Try looking at Chapter 11. Basic Texturing from my book to understand the fixed-function texture configuration.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!