When I load a texture using the code below:
WWW www = new WWW(textureName);
yield return www;
renderer.material = new Material(Shader.Find("Diffuse"));
Texture tex = www.texture;
tex.filterMode = FilterMode.Trilinear;
renderer.material.mainTexture =tex;
The texture does not come with mipmaps, how can I tell unity to generate the mipmaps?
Answer
You could simply create a new texture using the width/height information from the WWW's texture, and pass true
to the mipmap
parameter of the constructor. Then you can use the GetPixels and SetPixels methods to copy the data over (the texture returned from the WWW object is read-only so you probably can't modify it directly).
See also: http://answers.unity3d.com/questions/2814/how-do-i-generate-mipmaps-at-runtime
No comments:
Post a Comment