Beginner in Unity, having issues with textures along the Z axis

hello, I’m fairly new when it comes to unity and I’ve been working on a project. Part of my project is procedural generation and I’ve been watching a video series helping me tremendously, but there is a fairly big problem that I’ve come across that the videos do not cover. The problem is all wall textures along the z axis are stretched like so.

The scripts I are mainly using are from this github page Move map generation to design-time instead of run-time by MehYam · Pull Request #6 · SebLague/Procedural-Cave-Generation · GitHub being the map generator and mesh generator.

I would very much appreciate any insight into this problem as it has stumped me, if there is any other items that I could post that will help find a solution please let me know.

What you want is something called Tri-planar texturing. Give me a couple of mins to find a code example. :slight_smile:

EDIT: nvm, found an article and wrote it myself, here you go:

Shader "Custom/Tri-Planar" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
       
        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
            float3 worldNormal;
            float3 worldPos;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        void surf (Input IN, inout SurfaceOutputStandard o) {
            /*----------Tri-planar tex coords----------*/
            half3 blending = abs(IN.worldNormal);
            blending = normalize(max(blending, 0.00001));
            float b = (blending.x + blending.y + blending.z);
            b /= half3(b,b,b);

            // Albedo comes from a texture tinted by color
            fixed4 cx = tex2D (_MainTex, IN.worldPos.yz) * _Color;
            fixed4 cy = tex2D (_MainTex, IN.worldPos.xz) * _Color;
            fixed4 cz = tex2D (_MainTex, IN.worldPos.xy) * _Color;

            fixed4 tex = cx * blending.x + cy * blending.y + cz * blending.z;

            o.Albedo = tex.rgb;
            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = tex.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}