Question by
VIPINSIRWANI · Feb 13, 2019 at 08:59 AM ·
textureruntimenormalmap
Import Normal Map at Run Time and access Border Mip Map property of texture?
I am able to generate Normal map at run time.
But I want to enable border mip map property of textrue (Just like in editor) when assigning it on material.
My Code look like :
public void bumpConvert(Texture2D bumpTexture)
{
Texture2D normalTexture = new Texture2D (bumpTexture.width, bumpTexture.height, TextureFormat.RGBA32, true);
normalTexture.filterMode = FilterMode.Bilinear;
normalTexture.wrapMode = TextureWrapMode.Repeat;
Color[] pixels = bumpTexture.GetPixels(0, 0, bumpTexture.width, bumpTexture.height);
float r;
float g;
float b;
float a;
for (int i = pixels.Length - 1; i >= 0; i--){
Color colour = pixels[i];
r = g = b = colour.g;
a = colour.r;
pixels[i] = new Color(r, g, b, a);
}
normalTexture.SetPixels(pixels);
normalTexture.Apply(true);
bumpTexture = normalTexture;
this.GetComponent< Renderer > ().material.SetTexture("_BumpMap", bumpTexture);
}
Here bumpTexture is the image which I am loading and passing to bumpConvert method at run time.
After this everything looks fine but only problem is I am not able to enable Border Mip Map.
Comment
Your answer
Follow this Question
Related Questions
How can I set an Image (PNG) from a URL to be the material of a sphere ?? 0 Answers
Base64 to texture decoding, js -> webgl 1 Answer
Standard Shader 0 Answers
Draw Curve on texture in Unity 0 Answers
Object textures have disappeared. 0 Answers