6.5 C
New York
Wednesday, April 2, 2025

How do you make tiling property work with customized shader in unity?


I’ve created a customized shader primarily based on unity commonplace floor shader
however tiling and offset properties do not work in any respect.
Solely the albedo texture slot’s tiling works.
How do you make tiling work for particular person texture slots?

My customized shader code simply in case:

Shader "Customized/customized shader" {
Properties {
    _Color ("Shade", Shade) = (1,1,1,1)
    _MainTex ("Albedo (RGB)", 2D) = "white" {}
    _NormalTex ("Regular map", 2D) = "bump" {}
    _BumpScale ("Bump scale", Vary(0,1)) = 1.0
    _Glossiness ("Smoothness", Vary(0,1)) = 0.5
    _Metallic ("Metallic", Vary(0,1)) = 0.0
}
SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200
    
    CGPROGRAM
    // Bodily primarily based Normal lighting mannequin, and allow shadows on all mild sorts
    #pragma floor surf Normal fullforwardshadows

    // Use shader mannequin 3.0 goal, to get nicer trying lighting
    #pragma goal 3.0

    sampler2D _MainTex;
    sampler2D _NormalTex;

    struct Enter {
        float2 uv_MainTex;
    };

    half _Glossiness;
    half _Metallic;
    half _BumpScale;
    fixed4 _Color;

    void surf (Enter IN, inout SurfaceOutputStandard o) {
        // Albedo comes from a texture tinted by colour
        fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
        o.Albedo = c.rgb;
        // Metallic and smoothness come from slider variables
        o.Metallic = _Metallic;
        o.Smoothness = _Glossiness;
        o.Alpha = c.a;

        fixed3 n = UnpackScaleNormal(tex2D(_NormalTex, IN.uv_MainTex), _BumpScale);
        o.Regular = n;
    }
    ENDCG
}
FallBack "Diffuse"

}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles