Hi everyone,

I'm having a hard time getting the ShaderMaterial of my MeshInstance, my implementation is shown on the image below; I just want to change the shader parameter in script I'm using C#.

Many thanks in advanced for any help,

Dexter

Oopps got it!

    /// <summary>
    /// Called when the node enters the scene tree for the first time. 
    /// </summary>
    public override void _Ready()
    {
        
        MeshInstance   mMesh      = this;
        Material       mMat       = mMesh.GetSurfaceMaterial(0);
        ShaderMaterial mShaderMat = mMat as ShaderMaterial;

        //--> Get the Plane parameter from shader 
        //
        Plane mDefaultPlane = (Plane)mShaderMat.GetShaderParam("plane");

        //-->  Set new value on Plane parameter to shader 
        //
        Plane mReplacePlane = new Plane(1, 1, 1, 0);
        //
        mShaderMat.SetShaderParam("plane", mReplacePlane );                

    }

I changed the topic from a discussion to a question and marked your post as the answer :smile:

2 years later