Here is the code:
Shader "World Shader" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _TextureScale ("Texture Scale", float) = 1
//[NoScaleOffset] _BumpMap ("Normalmap", 2D) = "bump" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 250
CGPROGRAM
#pragma surface surf Lambert noforwardadd
sampler2D _MainTex;
float _TextureScale;
//sampler2D _BumpMap;
struct Input
{
float2 uv_MainTex;
float3 worldPos;
float3 worldNormal;
};
float myFmod(float a, float b)
{
float c = frac(abs(a / b)) * abs(b);
return c;
}
void surf (Input IN, inout SurfaceOutput o)
{
float x = IN.worldPos.x * _TextureScale;
float y = IN.worldPos.y * _TextureScale;
float z = IN.worldPos.z * _TextureScale;
float isUp = abs(IN.worldNormal.y);
float2 offset = float2(myFmod(z + x * (1 - isUp), 0.0625), myFmod(y + x * isUp, 0.0625));
fixed4 c = tex2D(_MainTex, IN.uv_MainTex + offset);
o.Albedo = c.rgb;
o.Alpha = 1;
//o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
}
ENDCG
}
FallBack "Mobile/Diffuse"
}
I switched my unity project to URP and my custom shader stopped working :( How can I make my custom shader support URP? How can I convert it?
Before trying to convert your shader code into URP, you can try to let Unity convert it for yourself if your shader is simple enough.
Select the materials your shader is applied on. Edit -> Rendering -> Materials -> Convert the select Built-in Materials to URP.
Convert material to URP