Beispiel #1
0
        void EnsureHookedLightSource(Light light)
        {
            if (!light)
            {
                return;
            }

            if (light.commandBufferCount == 2)
            {
                return;
            }

            //Debug.Log("Hooking scattering command buffers on light source: " + light.name);

            // NOTE: This doesn't really play nicely with other users of light events.
            //       Currently not an issue since this code was written pre-5.1 (and light events
            //       are a new feature in 5.1), but might need a proper solution in the future.
            light.RemoveAllCommandBuffers();

            if (m_occlusionCmdAfterShadows != null)
            {
                m_occlusionCmdAfterShadows.Dispose();
            }
            if (m_occlusionCmdBeforeScreen != null)
            {
                m_occlusionCmdBeforeScreen.Dispose();
            }

            m_occlusionCmdAfterShadows      = new UnityEngine.Rendering.CommandBuffer();
            m_occlusionCmdAfterShadows.name = "Scatter Occlusion Pass 1";
            m_occlusionCmdAfterShadows.SetGlobalTexture("u_SMCascadedShadowMap", new UnityEngine.Rendering.RenderTargetIdentifier(UnityEngine.Rendering.BuiltinRenderTextureType.CurrentActive));
            m_occlusionCmdBeforeScreen      = new UnityEngine.Rendering.CommandBuffer();
            m_occlusionCmdBeforeScreen.name = "Scatter Occlusion Pass 2";

            light.AddCommandBuffer(UnityEngine.Rendering.LightEvent.AfterShadowMap, m_occlusionCmdAfterShadows);
            light.AddCommandBuffer(UnityEngine.Rendering.LightEvent.BeforeScreenspaceMask, m_occlusionCmdBeforeScreen);
        }
Beispiel #2
0
 private void SetTextureCommandBuffer(int id, Texture value)
 {
     commandBuffer.SetGlobalTexture(id, value);
 }