Version: Unity 6.2 Alpha (6000.2)
Language : English
Reflection Surface Shader examples in the Built-In Render Pipeline
Custom data Surface Shader example in the Built-In Render Pipeline

Vertex modifier Surface Shader example in the Built-In Render Pipeline

It is possible to use a “vertex modifier” function that will modify the incoming vertex data in the vertex ShaderA program that runs on the GPU. More info
See in Glossary
. This can be used for things like procedural animation and extrusion along normals. Surface ShaderA streamlined way of writing shaders for the Built-in Render Pipeline. More info
See in Glossary
compilation directive vertex:functionName is used for that, with a function that takes inout appdata_full parameter.

Here’s a Shader that moves vertices along their normals by the amount specified in the Material:

  Shader "Example/Normal Extrusion" {
    Properties {
      _MainTex ("Texture", 2D) = "white" {}
      _Amount ("Extrusion Amount", Range(-1,1)) = 0.5
    }
    SubShader {
      Tags { "RenderType" = "Opaque" }
      CGPROGRAM
      #pragma surface surf Lambert vertex:vert
      struct Input {
          float2 uv_MainTex;
      };
      float _Amount;
      void vert (inout appdata_full v) {
          v.vertex.xyz += v.normal * _Amount;
      }
      sampler2D _MainTex;
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
      }
      ENDCG
    } 
    Fallback "Diffuse"
  }
Reflection Surface Shader examples in the Built-In Render Pipeline
Custom data Surface Shader example in the Built-In Render Pipeline
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961