文档

Unity Engine


User Manual

Script Reference

Unity Engine


Setting the render state on the GPU

Resources for using commands in a subshader or shader pass that change the render state on the GPU.
阅读时间2 分钟最后更新于 23 天前

Use these commands within a Pass block to set the render state for that Pass, or within a SubShader block to set the render state for that SubShader and any Passes that it contains.

Page

Description

Enable conservative rasterization in a shaderUse the
Conservative
command to rasterize pixels that are partially covered by a triangle, regardless of coverage.
Set the culling mode in a shaderUse the
Cull
command to improve rendering efficiency by setting which polygons the GPU doesn't draw.
Set the depth bias in a shaderUse the
Offset
command to set the depth at which the GPU draws geometry.
Set the depth clip mode in a shaderUse the
ZClip
command to set how the GPU handles fragments that are outside the near and far clip planes.
Set the depth testing mode in a shaderUse the
ZTest
command to change the conditions of depth testing to achieve visual effects such as object occlusion.
Disable writing to the depth buffer in a shaderUse the
ZWrite
command to set whether the GPU renders to the depth buffer.
Check or write to the stencil buffer in a shaderUse the
Stencil
command to configure the stencil test, or configure what the GPU writes to the stencil buffer.
Set the blending mode in a shaderUse the
Blend
and
BlendOp
commands to set how the GPU combines the output of the fragment shader with the render target.
Set the color channels the GPU renders toUse the
ColorMask
command to prevent the GPU rendering to certain color channels, for example to render uncolored shadows.
Reduce aliasing with AlphaToMask modeUse the
AlphaToMask
command to set the GPU to modify multisample anti-aliasing (MSAA) to reduce aliasing un shaders that use alpha testing, such as vegetation shaders.
Group commands with the Category blockUse the
Category
block to group commands that set the render state, so you can inherit the grouped rendering state within the block.

Additional resources