Version: Unity 6.1 Alpha (6000.1)
Language : English
Surface Shader required directives reference for the Built-In Render Pipeline
Surface Shader input structure reference for the Built-In Render Pipeline

Surface Shader optional directives reference for the Built-In Render Pipeline

Transparency and alpha testing is controlled by alpha and alphatest directives. Transparency can typically be of two kinds: traditional alpha blending (used for fading objects out) or more physically plausible “premultiplied blending” (which allows semitransparent surfaces to retain proper specular reflections). Enabling semitransparency makes the generated surface shaderA program that runs on the GPU. More info
See in Glossary
code contain blending commands; whereas enabling alpha cutout will do a fragment discard in the generated pixelThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More info
See in Glossary
shader, based on the given variable.

  • alpha or alpha:auto - Will pick fade-transparency (same as alpha:fade) for simple lighting functions, and premultiplied transparency (same as alpha:premul) for physically based lighting functions.
  • alpha:blend - Enable alpha blending.
  • alpha:fade - Enable traditional fade-transparency.
  • alpha:premul - Enable premultiplied alpha transparency.
  • alphatest:VariableName - Enable alpha cutout transparency. Cutoff value is in a float variable with VariableName. You’ll likely also want to use addshadow directive to generate proper shadow caster pass.
  • keepalpha - By default opaque surface shadersA streamlined way of writing shaders for the Built-in Render Pipeline. More info
    See in Glossary
    write 1.0 (white) into alpha channel, no matter what’s output in the Alpha of output struct or what’s returned by the lighting function. Using this option allows keeping lighting function’s alpha value even for opaque surface shaders.
  • decal:add - Additive decal shader (e.g. terrain AddPass). This is meant for objects that lie atop of other surfaces, and use additive blending. See Surface Shader Examples
  • decal:blend - Semitransparent decal shader. This is meant for objects that lie atop of other surfaces, and use alpha blending. See Surface Shader Examples

Custom modifier functions can be used to alter or compute incoming vertex data, or to alter final computed fragment color.

  • vertex:VertexFunction - Custom vertex modification function. This function is invoked at start of generated vertex shaderA program that runs on each vertex of a 3D model when the model is being rendered. More info
    See in Glossary
    , and can modify or compute per-vertex data. See Surface Shader Examples.
  • finalcolor:ColorFunction - Custom final color modification function. See Surface Shader Examples.
  • finalgbuffer:ColorFunction - Custom deferred path for altering G-buffer content.

Shadows and Tessellation - additional directives can be given to control how shadows and tessellation is handled.

  • addshadow - Generate a shadow caster pass. Commonly used with custom vertex modification, so that shadow casting also gets any procedural vertex animation. Often shaders don’t need any special shadows handling, as they can just use shadow caster pass from their fallback.
  • fullforwardshadows - Support all light shadow types in Forward rendering pathThe technique that a render pipeline uses to render graphics. Choosing a different rendering path affects how lighting and shading are calculated. Some rendering paths are more suited to different platforms and hardware than others. More info
    See in Glossary
    . By default shaders only support shadows from one directional light in forward renderingA rendering path that renders each object in one or more passes, depending on lights that affect the object. Lights themselves are also treated differently by Forward Rendering, depending on their settings and intensity. More info
    See in Glossary
    (to save on internal shader variant count). If you need point or Spot Light shadows in forward rendering, use this directive.
  • tessellate:TessFunction - use DX11 GPU tessellation; the function computes tessellation factors. See Surface Shader Tessellation for details.

Code generation options - by default generated surface shader code tries to handle all possible lighting/shadowing/lightmapA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary
scenarios. However in some cases you know you won’t need some of them, and it is possible to adjust generated code to skip them. This can result in smaller shaders that are faster to load.

  • exclude_path:deferred, exclude_path:forward - Do not generate passes for given rendering path (Deferred ShadingA rendering path in the Built-in Render Pipeline that places no limit on the number of Lights that can affect a GameObject. All Lights are evaluated per-pixel, which means that they all interact correctly with normal maps and so on. Additionally, all Lights can have cookies and shadows. More info
    See in Glossary
    , Forward respectively).
  • noshadow - Disables all shadow receiving support in this shader.
  • noambient - Do not apply any ambient lighting or light probesLight probes store information about how light passes through space in your scene. A collection of light probes arranged within a given space can improve lighting on moving objects and static LOD scenery within that space. More info
    See in Glossary
    .
  • novertexlights - Do not apply any light probes or per-vertex lights in Forward rendering.
  • nolightmap - Disables all lightmapping support in this shader.
  • nodynlightmap - Disables runtime dynamic global illuminationA group of techniques that model both direct and indirect lighting to provide realistic lighting results.
    See in Glossary
    support in this shader.
  • nodirlightmap - Disables directional lightmaps support in this shader.
  • nofog - Disables all built-in Fog support.
  • nometa - Does not generate a “meta” pass (that’s used by lightmapping & dynamic global illumination to extract surface information).
  • noforwardadd - Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed per-vertex/SH. Makes shaders smaller as well.
  • nolppv - Disables Light Probe Proxy VolumeA component that allows you to use more lighting information for large dynamic GameObjects that cannot use baked lightmaps (for example, large Particle Systems or skinned Meshes). More info
    See in Glossary
    support in this shader.
  • noshadowmask - Disables Shadowmask support for this shader (both ShadowmaskA Texture that shares the same UV layout and resolution with its corresponding lightmap. More info
    See in Glossary
    and Distance Shadowmask).

Miscellaneous options

  • softvegetation - Makes the surface shader only be rendered when Soft Vegetation is on.
  • interpolateview - Compute view direction in the vertex shader and interpolate it; instead of computing it in the pixel shader. This can make the pixel shader faster, but uses up one more texture interpolator.
  • halfasview - Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized per vertex. This is faster, but not entirely correct.
  • approxview - Removed in Unity 5.0. Use interpolateview instead.
  • dualforward - Use dual lightmaps in forward rendering path.
  • dithercrossfade - Makes the surface shader support dithering effects. You can then apply this shader to GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
    See in Glossary
    that use an LOD GroupA component to manage level of detail (LOD) for GameObjects. More info
    See in Glossary
    component configured for cross-fade transition mode.

To see what exactly is different from using different options above, it can be helpful to use “Show Generated Code” button in the Shader Inspector.

Surface Shader required directives reference for the Built-In Render Pipeline
Surface Shader input structure reference for the Built-In Render Pipeline