Hi, everyone I was hoping if someone could help me to convert a shader I had been using in Unity. It is a worldspace shader so when you move the node its texture stays in place. Also, if two nodes both have this shader and texture they combine together seamlessy, like this:

Here is the existing code that is used in this image:

// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Unlit/Worldspace"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {           
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag               
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);

                // Gets the xy position of the vertex in worldspace.
                float2 worldXY = mul(unity_ObjectToWorld, v.vertex).xy;
                // Use the worldspace coords instead of the mesh's UVs.
                o.uv = TRANSFORM_TEX(worldXY, _MainTex);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {                   
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}

Any help would be greatly appreciated!

For starters I think you can just try to use the SpatialMaterial with the World TriPlanar flag toggled on: https://docs.godotengine.org/en/3.1/tutorials/3d/spatial_material.html#flags https://docs.godotengine.org/en/3.1/tutorials/3d/spatial_material.html#triplanar-mapping

Then you can just convert the SpatialMaterial into a ShaderMaterial and get it as a code. https://docs.godotengine.org/en/3.1/tutorials/shading/shader_materials.html#converting-to-shadermaterial

3 years later