Sign in to follow this  
nickpike

Banding using shadow alpha mask

Recommended Posts

Hi all,I have attached a view of a gauge I am making that uses an alpha bitmap to add shadow to give the ball a 3D effect. The shadow is there and the original alpha mask had a gradual gradient of grey, but on the gauge the shadow effect is banded. I have read the SDK backwards. Any ideas how to get a smooth gradient.Many thanks,Nick.http://forums.avsim.net/user_files/84613.gif

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

This is a problem that comes up now and then, and is related to the fact that the alpha channel is limited to 256 levels. Even though the bitmap is 24 bit, any change in the alpha channel will cause the a drastic change in the appearance of your underlying texture. This is what causes your banding.Fortunately, there's a workaround - maybe.I'm thinking that your alpha channel and texture are applied seperately from the ball - that tis to say, the ball texture is not the one with the alpha channel. So, think about the colour you are applying the alpha channel to. If you created a black texture, and then applied an alpha channel, then you've created a texture that has 256 "colours" from "completely transparent" to "completely black". Instead, try using a dark grey colour (RGB - 127,127,127). Now you should notice a slightly gradual transition in your shadow, but it still won't be perfect. You will also have to adjust your actual alpha channel, since in your screenshot, it looks like you are using 10 - 12 levels to achieve your goal. now, you will be using 20 - 24 levels, and this will be a little more subtle.But, it still won't be perfect. The bottom line is that the alpha channel isn't really useful for showing gradual transitions like what you are trying to achieve. I think I read somewhere that the DXT5 format was supposed to use a 16 or 24 bit alpha channel, but it doesn't matter since this isn't used in FS2004, so maybe we have to wait until the next version.- Martin

Share this post


Link to post
Share on other sites

Many thanks for your reply. You are correct. I had an all black seperate bitmap with an added alpha channel image being the shadow image having a gradual change of grey gradient.I believe I followed your instructions properly and I made a new seperate grey bitmap (instead of the black) of 127, 127, 127. and added the original alpha image to the alpha channel. I have attached the result and as you can see, someting is not quite right.Thanks,Nick.

Share this post


Link to post
Share on other sites

Well that is really strange - that shouldn't have happened that way, so maybe something else got introduced here as well. Following my directions, you should have ended up with the same image, but with less obvious banding. When I said "something is not quite right", I just meant that the shading wouldn't be perfect, but that there would be less banding. - Martin

Share this post


Link to post
Share on other sites

Hi Martin and thanks for all your help. The question is that should the black be used as this is a transparent colour as used with FS2004 XML gauges, and the grey is not normally transparent.Nick.

Share this post


Link to post
Share on other sites

Well, I'm not sure exactly how you made your textures, so I made a couple assumptions. I assume that the ball part is just made with a regular texture. I assume that the shading is a seperate texture that has an alpha channel in order to provide a shadow. I hope this is right, since otherwise my idea may not be relevant to what you were talking about here.In my world, when I wanted to create a shadow effect like you were doing, I started with a black texture with an alpha mask. So some parts of the texture appeared black, and there was a transition into a transparent texture so that we could see the gauge behind the texture. The problem was that we could see this banding effect like you showed in your first picture.So, my idea is to smooth out the banding a little by using more levels in the alpha channel. You see the banding because you aare only using a few levels of alpha blending. If you use more, you will get a smoother result. But at the same time, you have a minimum and maximum value of alpha levels that you want to use. This correlates to the minimum and maximum level of "darkness" or "shadow" you wish to create. So, my idea is that instead of using 10 levels of the alpha channel (out of an available 256), we should try to use more, maybe 20 or 30 if possible. Of course, if you try to use 30 levels where you were using 10 before, then parts of teh shading will be too dark, or not dark enough. We can compensate for this by using a grey texture rather than a black one on our shade texture. Since grey is not as dark as black, we can use more alpha levels on our texture, which will result in a smoother effect.To illustrate what I am trying to talk about, please look at my picture that I made. Remember that the alpha channel is limited to 8 bits - 256 colours. If you compare the 24 bit example to the 8 bit example, then you might think it looks pretty close, but that doesn't tell the whole story, since my 8 bit example is using all 256 levels available in the alpha channel to create a smooth transition.Compare the 8 bit (256 colours) to the 4 bit (16 colours) and you will instantly recognize the banding which is causing you so much grief. In this example, we are only using 16 levels of alpha blending, and it looks really crappy. So, if we can figure out a way to use more levels of alpha blending rather than fewer, then we will finally be in business. Using a grey texture like I described above is one way, but it is really best when you only need lighter shadows. So, the answer may be to sacrifice a small amount of quality and compromise with some more subtle shadows and some limited banding.http://forums.avsim.net/user_files/84749.jpgBut wait, there's more...Something that I hadn't even thought of is the limitations of graphics when used on gauges. I know that 2D panels seem to get rendered as 8-bit for some reason (maybe just my system?), so I wonder if gauges are the same. This would also explain the banding effect you are seeing.- Martin

Share this post


Link to post
Share on other sites

Many thanks for the further info. I have been attempting your suggestions but getting no result. Would you be kind enough to provide a step by step procedure. I have PSP, Imagetool and DXTbmp.Your help would be greatly appreciated.Nick.

Share this post


Link to post
Share on other sites

Well, I don't really have time for a step-by-step procedure, but I'm not sure it would be useful anyway since a lot of it will depend on your specific project. There isn't a universal rule that will work on every bitmap - you sort of have to experiment and try different things out to see if you are getting the results you were looking for. I provided a couple ideas that have worked for me in the past. Also, I'm not a graphics espert, so a lot of what I've learned has come from these forums. I use the same software you do, so if you need help with alpha channels, you might try searching back in the forum, since that's where I got a lot of my information.- Martin

Share this post


Link to post
Share on other sites

OK, well thanks for the help to date. I have searched the forums but I'll give it another go. I keep picking up snippets of information and maybe the pieces of this jigsaw will fall into place. The research continues.Cheers,Nick.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this