Define imported texture as normal map in script?

Hey guys,

I’m trying to import a normal map from an external location at run time.

It imports fine, but as it’s just brought in as a regular texture, Unity doesn’t know to handle it as a normal map - and therefore doesn’t display correctly when applied to the material’s bump map slot.

Any idea what the script for defining a texture as a normal map is?

Cheers,
James

Sod it, just wrote my own shader that doesn’t rely on Unity’s own normal mapping.

Hello James, I read that you manage to load a texture from external location at runtime, right now I’m trying to do the same thing, I generate a texture from a flash app locally and then launch a small app in unity that should load that texture to them apply it to a 3d model, I would appreciate a lot any advise or code example on how I could achieve this, thanks.

you would use WWW to load it from the harddisk if you are on a standalone application (alternatively System.IO.File.ReadAllBytes and Texture2Ds LoadImage)

Webapplication can not load from anywhere but the web

I’d also like to try this out. Farfarer, could you share your knowledge with us?

The code’s pretty much there on the Unity Script Reference site for WWW;
Unity - Scripting API: WWW (first block of code there)

Bear in mind that the Web Player can only load things from the domain it is hosted on.

Also that, by default, it will only load JPEG or PNG files as textures.

Hi. Could you please share your shader with me? I’d like to achieve similar thing. Using Texture2D.LoadImage or WWW.texture is neither able to import texture as normalmap.

I’m sorry to remove old cows from the ditch, but I’m still having the same problem: loading a texture from the resources folder (either with readAllBytes / LoadImage or UnityWebRequestTexture.GetTexture) yields an albedo texture. Unity does not recognize that I want it to be a normalMap. Not even when I apply it to the “_NormalMap” texture in a shader.
The material looks like the texture was applied as a normal 2D texture.
Am I missing something? I’m guessing that I need to set the texture to a “normal” type womewhere , but I can’t find it anywhere.

1 Like

hey! Did you manage to make it look like a normal map when adding it from script?