- Home /
Texture2D: pixel Specific alpha not working?
**Hi I basically want a texture with different pixels having different alpha values and this is not working..**
` public var alpha:float; function Start () {
// Create a new 2x2 texture ARGB32 (32 bit with alpha) and no mipmaps
var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);
texture.SetPixel(1, 0, Color(1.0, 0, 0, alpha));
texture.SetPixel(1, 0, Color.white);
texture.SetPixel(0, 1, Color.green);
texture.SetPixel(1, 1, Color(0,0,1,0.7));
// Apply all SetPixel calls
texture.Apply();
// connect texture to material of GameObject this script is attached to
renderer.material.mainTexture = texture;
}
`
Answer by ScroodgeM · Aug 23, 2012 at 08:23 PM
methinks your shader that you use for testing doesn't use alpha.
select Transparent-Diffuse shader in material to see alpha effect.
Answer by zandegran · Aug 24, 2012 at 01:37 PM
Thank you but it is not working
I want different pixels with different alpha....
hmmm... r u sure on your texture alpha is ignored? i see some different alphas on it... how do you check that alpha is ignored and what effect do you want to achieve... also try to create some really different alpha pixels - 0.1 and 0.9 for example... and set alpha-value in color setting from material to 1.0 to use only alpha value from texture.
Answer by zandegran · Aug 27, 2012 at 08:20 AM
This is a Hexagon on a rectangular plane the hexagon has a alpha value of 1(RGBA : 1,1,1,1) and the remaining area has value of .001 (RGBA : 0,0,0,0.001) I want the hexagon to be real opaque but it is not. transparent/diffuse I've also uploaded the texture (.js)
set color in material with transparent/diffuse also to 1,1,1,1
Answer by zandegran · Aug 27, 2012 at 09:07 AM
I got what I want... The right mode is Unlit/Transparent