- Home /
 
is this a mipmap problem?
Hi, I have this function where I add a alpha channel to a texture - and then use the shader downbelow on the texture. This works fine until I scale the object to a smaller size, why is this? - When I down scale the texture then the alpha I just add'd is not working and the start texture is displayed without the alpha.
thanks,
/Joe
Add alpha to texture
enter code here Texture2D addAlphaToTexture(Texture2D texture, Texture2D alphaTexture){
     Color[] textureColorArray = new Color[texture.width*texture.height];
     textureColorArray = texture.GetPixels(0);
     
     Color[] alphaArray = new Color[alphaTexture.width*alphaTexture.height];
     alphaArray = alphaTexture.GetPixels();
     
     Color[] mixedColorArray = new Color[texture.width*texture.height];
     
     for(int joe = 0; joe < textureColorArray.Length; joe++){
         
         if(alphaArray[joe].a != 0){
             mixedColorArray[joe] = textureColorArray[joe];
         }
     }
     texture.SetPixels( mixedColorArray, 0);    
     texture.Apply(false);
     return texture;
 }
 
 
 
               AlphaSelfIllum Shader
 enter code here
 Shader "AlphaSelfIllum" {
 Properties {
     _Color ("Color Tint", Color) = (1,1,1,1)
     _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
 }
 Category {
    Lighting On
    ZWrite Off
    Cull Back
    Blend SrcAlpha OneMinusSrcAlpha
    Tags {Queue=Transparent}
    SubShader {
         Material {
            Emission [_Color]
         }
         Pass {
            SetTexture [_MainTex] {
                   Combine Texture * Primary, Texture * Primary
             }
         }
     } 
 }
 
               }
Answer by TenCommander · Feb 02, 2012 at 12:08 PM
Solution
I found a solution, it was just to use a texture without mipmaps on the function like this
 enter code here
 Texture2D texture = new Texture2D(x, y, TextureFormat.ARGB32, false); 
 
               Thanks to me self.
Your answer
 
             Follow this Question
Related Questions
Disable mip mapping. 3 Answers
Access current mip level at fragment shader 1 Answer
Texture mipmap distance 1 Answer
RenderTexture to capture an area bigger than Screen on IOS 0 Answers
Texture Max Size Value related rule 1 Answer