Scripted Alpha causes artifacts on GUITexture

I know this has been asked before, but for the life of me i cant find the thread.

I have a GUITexture which has an Alpha of 0.5f - set using Unity. When I used a script to fade in the guitexture to the same alpha value, it looks different.

Its a bit hard to see, but trust me, its different - its a lot more obvious with some textures than other (file is PNG24)

cheers
Shaun

Bottom image is the good one - top is bad…

35473--1296--$picture_2_117.png
35473--1297--$picture_1_156.png

That’s an understatement. :wink: I literally cannot see a difference between those two. Although one possibility is that, when you fade in, the alpha is not stopping at precisely 0.5. It depends on how your code works…if you’re doing something like “if (alphaValue < 0.5)”, and one frame it’s 0.488 (for example) and the next it’s 0.508, then it would stop at 0.488. In that case, just make sure to set the value specifically at 0.5 as the last step.

–Eric

lol… yeah sorry if it seems a bit picky - but its really obvious on other types of textures. If you look at the aliasing on the rounded edges of the menubar background u can see its quite jagged.

i checked the opacity floats on my fade functions and after the fade-in completes its loop i manually set it to 0.5f. But still not working~~

Cheers
Shaun

Take a look at it in the inspector after fading is complete, is it the same color as if you set it up completely from the inspector?

Thanks! - that did it :wink:

The rgb’s were being set to 1.0f - normally that isn’t a problem but it seems to ‘brighten’ the texture in Unity - so as default I have to use r128,g128,b128 - why is that?

Cheers
Shaun

That was a “design decision” so that it’s possible to brighten the textures.

The ambient lighting property set via the project rendering settings effect your textures and world.

I’m working on a game where I don’t want any light information to effect my game world. So I deleted all lights and set my rendering ambient light to 100% white. This way the texture information is true to what is rendered.

Cheers

This was for gui textures. lights dont affect guitextures.

Ive started using the ‘brighten’ feature for GUI Textures - its actually really useful for simple rollover highlights(rather than having an ‘over’ texture).
nice one guys :wink:

Cheers
Shaun

While we’re on this topic – rescaling guitextures by setting the pixel offsets seems to mess up the alpha channels – even when the rescale is a power of 2. The larger is 100% the smaller 50% exactly.

35656--1302--$picture_4_195.png
35656--1303--$picture_3_366.png