Normalmap/bumpmap on runtime from www.texture?

Please can anyone enlight me if this is possible? I would like to generate normal map from downloaded texture to minimize bandwidth usage. I know that generating from diffuse texture is quality compromise but I can live with that..

I solved MIPMAP generation already. Source:unitianswers

var www:WWW = new WWW (url);
yield www;
Debug.Log("Converting to MIPMAPS");
var tex1 = www.texture; 
var tex2 = new Texture2D(tex1.width, tex1.height); 
Debug.Log("Converting DONE");

Searching forums was no help. Doc's neither.


You don't need to use GetPixels/SetPixels like that to make mipmaps; just create a texture first and then use LoadImageIntoTexture. There isn't any quality compromise, unless you're using jpeg instead of png. And yes, a normalmap is a texture like any other texture, so it's possible. I don't see how this is "minimizing bandwidth usage" though.

There are shaders that can create a normal map from a diffuse texture map, from memory there is one in AMD(ATI) RenderMonkey, but sure you can find plenty of other examples online.

So one method (I guess you need Unity Pro for this though), is to use the shader with renderToTexture to generate your normal mapped textures at runtime. This should be very fast compared to get/set pixel.

Alternatively you can use get/set pixel and simply convert the shader code into javascript/c#.

Edit: You might find this page useful for obtaining better quality normalmap data.