文档

Unity Engine


User Manual

Script Reference

Unity Engine


Examples of writing a custom shader in URP

Examples of shader code in URP.
阅读时间1 分钟最后更新于 25 天前

Techniques for writing shaders in the Universal Render Pipeline (URP).
Each example covers some extra information compared to the basic shader example. If you're new to writing shaders using Unity's ShaderLab language, consider going through the sections in the order of appearance on this page.

Page

Description

Create a sample scene in URPCreate a sample scene for writing shaders in URP.
Write an unlit basic shader in URPAn example of a basic URP shader that fills a mesh shape with a color.
Write an unlit shader with color input in URPAn example of a URP shader that adds the Base Color property to a material.
Draw a texture in a shader in URPAn example of a URP shader that draws a texture on a mesh.
Visualize normal vectors in a shader in URPAn example of a URP shader that visualizes the normal vector values on a mesh.
Write depth only in a shader in URPAdd a depth prepass that writes the depth of objects before the opaque and transparent passes.
Reconstruct world space positions in a shader in URPAn example of a URP shader that reconstructs the world space positions for pixels using a depth texture and screen space UV coordinates.