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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Where can I find the source code of the Vert and Frag in HDRP lit shader?

Discussion in 'Shaders' started by Bearaphics, Mar 8, 2023.

  1. Bearaphics

    Bearaphics

    Joined:
    Feb 15, 2023
    Posts:
    2
    Inside the HDRP lit shader, there are
    #pragma vertex Vert
    and
    #pragma fragment Frag
    but no definitions. I assume they are predefined, but I can't find them in all libraries included. Where are they?
     
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    That depends on the pass, since it will do (at least) 2 passes, not counting debug/picking/meta passes, shadow passes, etc, etc, etc. It also might be forward or deferred depending on various configuration options. For example, the deferred G-Buffer fragment pass will start here:

    https://github.com/Unity-Technologi...derPipeline/ShaderPass/ShaderPassGBuffer.hlsl

    That doesn't do much on its own though since it relies on other functions having been included/defined before it's included. Eg the fragment pass there will want GetSurfaceAndBuiltinData which is defined differently for different surfaces. For a Lit shader, that's probably defined somewhere in here...

    https://github.com/Unity-Technologi...-definition/Runtime/Material/Lit/LitData.hlsl

    That's going to reference a bunch of other files. There's probably 30,000 lines of HLSL code included in various places/ways.
     
    Bearaphics likes this.
  3. Bearaphics

    Bearaphics

    Joined:
    Feb 15, 2023
    Posts:
    2
    Thanks for the valuable information. You are right, they are pass-dependent. I haven't yet looked up all passes, but most of them are under HDRP/Runtime/RenderPipeline/ShaderPass