Version: Unity 6.5 Beta (6000.5)
Language : English
Surface Shaders and rendering paths in the Built-In Render Pipeline
Set the lighting model in a Surface Shader in the Built-In Render Pipeline

Create a surface shader in the Built-In Render Pipeline

Important: The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
For more information on migration, refer to Migrating from the Built-In Render Pipeline to the Universal Render Pipeline and Render pipeline feature comparison.

Follow these steps:

  1. Add a CGPROGRAM block to the SubShader block in your shaderA program that runs on the GPU. More info
    See in Glossary
    code, not the Pass block. Unity automatically creates multiple passes when it compiles the surface shaderA streamlined way of writing shaders for the Built-in Render Pipeline. More info
    See in Glossary
    .
  2. Add a #pragma surface [surfaceFunction] [lightModel] directive.

Surface shaders aren’t compatible with HLSLPROGRAM blocks, but you can use HLSL inside a CGPROGRAM block. For more information, refer to Shader code blocks in ShaderLab reference.

Example

Shader "Example/Diffuse Simple" {
  SubShader {
    Tags { "RenderType" = "Opaque" }

    CGPROGRAM

    #pragma surface surf Lambert

    struct Input {
        float4 color : COLOR;
    };

    void surf (Input IN, inout SurfaceOutput o) {
        o.Albedo = 1;
    }

    ENDCG
  }
  Fallback "Diffuse"
}

Here’s how it looks like on a model with two Lights set up:

Basic surface shader example.
Basic surface shader example.
Surface Shaders and rendering paths in the Built-In Render Pipeline
Set the lighting model in a Surface Shader in the Built-In Render Pipeline