1

我一直在尝试使用 ShaderGraph (Unity 2019.3.0f3)从 Tim-C(这一切似乎都已经过时,甚至评论中发布的修复)实现这种效果,但据我所知,你不能做到这一点ShaderGraph,所以在查看了 ShaderLab 文档上的这个页面后,我想出了以下使用我制作的着色器图的着色器。

使用这个着色器可以很好地显示着色器图:

Shader "Custom/BlockPreview_ZWrite"
{
    Properties
    {
        //Has the same name as 'Reference' in shader graph.
        PreviewColor("Hologram Color", Color) = (0.90, 0.90, 0.90, 0.20)
    }

    SubShader
    {

        Tags {
            "Queue" = "Transparent"
            "RenderType" = "Transparent"
            "RenderPipeline" = "UniversalPipeline"
        }

        UsePass "Shader Graphs/BlockPreview_Graph/Pass"

    }

}

所以我尝试添加一个 ZWrite 通道,但这个着色器将什么都不显示(但场景视图中的轮廓仍然像它在那里一样工作):

Shader "Unlit/BlockPreviewZ"
{
    Properties
    {
        //Has the same name as 'Reference' in shader graph.
        PreviewColor("Hologram Color", Color) = (0.90, 0.90, 0.90, 0.20)
    }

    SubShader
    {

        Tags
        {
            "Queue" = "Transparent"
            "RenderType" = "Transparent"
            "RenderPipeline" = "UniversalPipeline"
        }

        Pass                                                                                           //
        {                                                                                              //
            ZWrite On                                                                                  //
            ColorMask 0   //Commenting out this line will just display a solid white object.           //
        }                                                                                              //

        UsePass "Shader Graphs/BlockPreview_Graph/Pass"

    }

}

除了我在这里写的以外,我对 ShaderLab 的经验或知识很少,那么我可以做些什么来制作我需要添加UsePass的 pass 的工作?ZWrite

4

1 回答 1

4

事实证明,仅使用第一遍的 LWRP/URP 是一个“功能”。https://issuetracker.unity3d.com/issues/lwrp-only-first-pass-gets-rendered-when-using-multi-pass-shaders

我可能会通过使用两个相互叠加的渲染网格来解决这个问题。一个将执行 ZWrite(第一个),另一个将只是普通的着色器图。

更新这有效: 网格渲染器的“材料”数组的屏幕截图。

于 2019-12-19T05:16:29.563 回答