Importing and configuring Normal Maps at runtime ?


I’d like to know if it’s possible to import normal maps at runtime ?

Until now, I was importing all the textures I needed and configuring them in the Editor (selecting the right type of texture, adjusting the bumpiness value for the normal maps, etc). Is it possible to do it by code ?

Each texture has it’s own behavior and the bumpiness value isn’t always the same from one to another, so I have to set this parameter, but I don’t know if I can access it via script.

Thanks !

You can freely assign all variables that are listed under the shader’s Properties. Open the shader and look at the top. Each variable declaration will also include the type (2D for a texture, Range for a float value, and so on). You just access the object’s Renderer’s material and change the values around to whatever strikes your fancy.

I guess you could create a dictionary at game start that holds the materials as keys and the right bump values (float) as values.

I managed to do what I want.

I created proper normalmaps from the heightmaps I had with CrazyBump. Then I created a custom Bumped Diffuse shader to handle non-NormalMaps textures. And now it works !

Thanks for your answer by the way.