0

I am working on the Unity Learn 3D Game Kit. But in URP project, shaders are not working as expected. So i have to convert them to URP.Below code is from 3D Game Kit shader. I am not good at shader coding. Anyone, please convert this to URP.

SubShader {
    Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" 
          "IgnoreProjector"="True" }
    #pragma surface surf Standard fullforwardshadows vertex:vert addshadow 

    sampler2D _MainTex;
    sampler2D _Noise;
    sampler2D _Gradient;
    sampler2D _Normal;
    sampler2D _MetallicSmooth;
    sampler2D _AO;
    half _Glossiness, _Metallic, _Cutoff, _EdgeSize, _NoiseStrength, _DisplaceAmount;
    half4 _Color, _EdgeColor1, _Emission;

    struct Input {
        float2 uv_Noise;
        float2 uv_MainTex;
        fixed4 color : COLOR0;
        float3 worldPos;
    };

    void vert (inout appdata_full v, out Input o) {
        UNITY_INITIALIZE_OUTPUT(Input,o);
        float3 pos = mul((float3x3)unity_ObjectToWorld, v.vertex.xyz);
        pos.x += _Time*30;
        float4 tex = tex2Dlod(_Noise, float4(pos, 0)*0.5);
        float4 Gradient = tex2Dlod (_Gradient, float4(v.texcoord.xy,0,0));
        float mask = smoothstep(_Cutoff, _Cutoff - 0.3, 1-Gradient);
        v.vertex.xyz += v.normal*tex*mask*_Cutoff*_DisplaceAmount;
      }
 
    void surf (Input IN, inout SurfaceOutputStandard o) {
        half3 Noise = tex2D (_Noise, IN.uv_Noise);
        half4 MetallicSmooth = tex2D (_MetallicSmooth, IN.uv_MainTex);
        #if _USE_GRADIENT_ON
        half3 Gradient = tex2D (_Gradient, IN.uv_MainTex);
        half Edge = smoothstep(_Cutoff, _Cutoff - _EdgeSize, 1-(Gradient + Noise.r*(1- 
       Gradient)*_NoiseStrength));
        #else
        half Edge = smoothstep(_Cutoff, _Cutoff - _EdgeSize, 1-Noise.r);
        #endif
        fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
        fixed3 EmissiveCol = c.a * _Emission;
        o.Albedo = c * _Color;
        o.Occlusion = tex2D (_AO, IN.uv_MainTex);
        o.Emission = EmissiveCol + _EdgeColor1 * Edge;
        o.Normal = UnpackNormal (tex2D (_Normal, IN.uv_MainTex));
        o.Metallic = MetallicSmooth.r * _Metallic;
        o.Smoothness = MetallicSmooth.a * _Glossiness;
        clip(1-Edge - _Cutoff);
    }
    ENDCG
     }
     FallBack "Diffuse"
 }
4
  • How far did you get? What exactly is the problem? Do you get errors? If so, what are those? Commented Sep 6, 2024 at 16:57
  • I know nothing about shaders. That's why I posted whole shader. Commented Sep 7, 2024 at 1:17
  • Did you try using AI tools to do that? Also why are you trying to work with that shader in URP project? Just create normal built-in renderer project or search for URP shaders. Commented Sep 9, 2024 at 10:55
  • I’m voting to close this question because poster is asking for someone to convert the shader code without any specific question or attempt. Commented Sep 9, 2024 at 20:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.