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.

Standard Surface Shader not working in URP

Discussion in 'Universal Render Pipeline' started by Cjmaster, Apr 1, 2020.

  1. Cjmaster

    Cjmaster

    Joined:
    Aug 12, 2017
    Posts:
    2
    Hey Guys,


    im trying to create a Standard Surface Shader for my mesh.
    I have a custom shader with very simple code:

    Code (CSharp):
    1.         void surf (Input IN, inout SurfaceOutputStandard o)
    2.         {
    3.             o.Albedo = float3(0, 1, 0);
    4.         }
    its setting everything to green.

    But if i have my material using it, it just show the fallback pink color.



    Is there something im missing?

    If you need more information just ask. Im not quite sure which informations are all necessary.
     

    Attached Files:

  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,162
    Surface shaders are no longer a thing in URP/HDRP.

    Your best bet is to use Shader Graph instead.
     
  3. Cjmaster

    Cjmaster

    Joined:
    Aug 12, 2017
    Posts:
    2
    Hey awesome for you answer. But im totaly lost with the graph.

    Im Currently trying to follow this tutorial:


    and Trying to transcript the Surface Shader to a Unlit Shader Graph:

    So far my results in the Picture.

    Im getting minHeight and maxHeight from the Material(this is working in the Material its set minHeight = 0, maxHeight = 93)

    And i added a Position node to get the world position. Hopefully for every Pixel? Im not quite sure what he is returning.

    Afterwards i have the custom function:
    Code (CSharp):
    1. result = saturate((value.y-a)/(value.y-b));
    which should give me a float value in a range based on my pixel height.

    Then im setting the color. It should end in a way that my low surface on a mesh are black and my uperonce getting somewhere close to white.

    Result is everything is just black.

    Im a bit quite lost with the Graph. I try the "Tutorial" but i would like to have a quick approach for my fairly easy task. Before i do a deep dive into shader graph.

    Can someone give my some hints?
    What am i missing and is this Shader Graph called like the old Surface Shader every time?
     

    Attached Files:

  4. nairbynairb

    nairbynairb

    Joined:
    Dec 8, 2018
    Posts:
    3


    Hey man, I was just trying to do this tutorial too and I came up with a way to do it in shader graph..
    Here:
     

    Attached Files:

    Snubber likes this.
  5. nairbynairb

    nairbynairb

    Joined:
    Dec 8, 2018
    Posts:
    3


    I realized on the next step he blended between the colours. While this isn't as nice as his (blend distances) it does blend between the colours:
     

    Attached Files:

    Snubber likes this.
  6. Snubber

    Snubber

    Joined:
    Jan 20, 2020
    Posts:
    65
    Does anyone know how to do this with the textures?
     
  7. Snubber

    Snubber

    Joined:
    Jan 20, 2020
    Posts:
    65
    I figured it out and made a youtube tutorial that describes the process as well as has a download for a working Unity project:

    I hope this helps.
     
  8. amitDklein

    amitDklein

    Joined:
    Apr 10, 2017
    Posts:
    20
    The names are different in URP.

    You can look here to see that the new shader name is.
     
  9. MrFurlan

    MrFurlan

    Joined:
    Sep 25, 2020
    Posts:
    1
    if you add a inverse lerp with the minHeight and maxHeight and the world y position, after the split you can work with the values that are in the video
     
  10. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,452
    There's also Better Shaders, which is a surface shader replacement system for all pipelines. It's pretty easy to convert existing surface shaders over if graph's aren't your thing or you find you hit the limits of the shader graph.