Changing the Heightmap of the Shader during rendering

I am using a ‘Tessellation/Bumped Specular (displacment)’ Shader and I want to change the heightmap during the rendering by C# code. I could not find a method to change the heightmap. I am a beginner… please give me some help by code.

Shader tx = GetComponent<Renderer> ().sharedMaterial.shader as Shader;

At this moment my first frame looks like this… done by drag and drop.

Hi @Pascal_Kelm , you should use the parameter _PARALLAXMAP. Hava a look to this link:

1 Like

Thanks. I am a total beginner in Unity. I have some experience in C#. Could you give me a small example to set/get the heightmap in the code?

public Texture2D normalMapTexture;

...
// assign texture
Renderer renderer = GetComponent<Renderer>();        
renderer.material.EnableKeyword ("_NORMALMAP");
renderer.material.SetTexture("_BumpMap", normalMapTexture);
...
1 Like

@Jordi-Bonastre It is not updating the heightmap. Do you see a mistake

void Update () {
        if (vr_objects.Count () > 0) {
            int index = (int)(Time.time * 30);       
            index = index % vr_objects.Count ();
            if (index < vr_objects.Count ()) {

                // Displacement map - not working                       
                renderer.material.EnableKeyword ("_PARALLAXMAP");
                renderer.material.SetTexture("_PARALLAXMAP", disp_tex[index]);

                //Moving plane - works
                Vector3 vec = new Vector3 (0, transform.position.y, (float) vr_objects[index].Rel_Position); // transform.position.z + 1);
                transform.position = vec;
            }
        }
    }

Ahhh… Thanks @Jordi-Bonastre

renderer.material.EnableKeyword ("_PARALLAXMAP");
                renderer.material.SetTexture("_ParallaxMap", disp_tex[index]);