Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Simple shader works in Scene view, but not in Game view

Discussion in 'Shaders' started by Steven-1, Nov 24, 2023.

  1. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    453
    I have this fairly simple shader:

    Code (CSharp):
    1. Shader "Custom/Moon"
    2. {
    3.     Properties
    4.     {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    7.         _BumpMap("Normal (RGB)", 2D) = "bump" {}
    8.     }
    9.     SubShader
    10.     {
    11.         Tags { "RenderType"="Opaque" }
    12.         LOD 200
    13.         Blend OneMinusDstColor One
    14.  
    15.         CGPROGRAM
    16.         #pragma surface surf Standard
    17.         #pragma target 3.0
    18.  
    19.         sampler2D _MainTex;
    20.         sampler2D _BumpMap;
    21.  
    22.         struct Input
    23.         {
    24.             float2 uv_MainTex;
    25.         };
    26.  
    27.         fixed4 _Color;
    28.  
    29.         void surf (Input IN, inout SurfaceOutputStandard o)
    30.         {
    31.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    32.             o.Albedo = c.rgb;
    33.             o.Metallic = 0;
    34.             o.Smoothness = 0;
    35.             o.Occlusion = 0;
    36.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
    37.         }
    38.         ENDCG
    39.     }
    40.     FallBack "Diffuse"
    41. }
    It works correctly in the scene view, but in game view it renders as if "Blend OneMinusDstColor One" isn't there, and it somehow flickers (as if the light increases intensity at times)

    Any ideas why?
     
  2. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    453
    Apparently it was because I ddin't specify the renderqueue, so it works now
     
    stefnobel likes this.