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 infodecal: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 infofinalcolor: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 infotessellate: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 infonoshadow
- 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 infonovertexlights
- 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.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 infonoshadowmask
- Disables Shadowmask support for this shader (both ShadowmaskA Texture that shares the same UV layout and resolution with its corresponding lightmap. More infoMiscellaneous 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 infoTo see what exactly is different from using different options above, it can be helpful to use “Show Generated Code” button in the Shader Inspector.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.