Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Not sure if this goes here... Its a question about shaders

Discussion in 'Scripting' started by Jinngineer, Oct 12, 2021.

  1. Jinngineer

    Jinngineer

    Joined:
    Apr 22, 2020
    Posts:
    41
    Hello,

    I have a question but im not sure if this goes here cause its not theoretically C# but about shaders.

    Ive been following CatLike Codings tutorials about the basics of Unity and on the 2nd one he started discussing shaders.

    The code is supposed to cause the colors of the instantiated prefab to change with its position on the y coordinate, but the color always remains black.

    The shader is attatched to the matieral shader option, and the material is attached to the prefab.

    If this is the wrong location for such questions i do apologise.

    Code (csharp):
    1.  
    2.  
    3. Shader "Graph/Point Surface"
    4. {
    5.    Properties{
    6.        _Smoothness("Smoothness", Range(0,1)) = 0.5
    7.    }
    8.        SubShader{
    9.        CGPROGRAM
    10.    #pragma surface ConfigureSurface Standard fullforwardshadows
    11.    #pragma target 3.0
    12.        struct Input {
    13.                float3 worldPos;
    14.            };
    15.        float _Smoothness;
    16.        void ConfigureSurface(Input input, inout SurfaceOutputStandard surface) {
    17.            surface.Albedo.rg = input.worldPos.xy * 0.5 + 0.5;
    18.            surface.Smoothness = _Smoothness;
    19.        }
    20.        ENDCG
    21.  
    22.    }
    23.  
    24.        FallBack "Diffuse"
    25. }
    26.  
    27.  
    28.  
    29.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,529
  3. Jinngineer

    Jinngineer

    Joined:
    Apr 22, 2020
    Posts:
    41
    OMG, i cant believe i missed that.... I must be blind. Thank you very much :)