static void BeginRender()
    {
        if (s_command_buffer == null)
        {
            s_command_buffer      = new CommandBuffer();
            s_command_buffer.name = "Hair";
            s_command_buffer.IssuePluginEvent(HairWorksIntegration.hwGetRenderEventFunc(), 0);
        }

        var cam = Camera.current;

        if (cam != null)
        {
            Matrix4x4 V   = cam.worldToCameraMatrix;
            Matrix4x4 P   = GL.GetGPUProjectionMatrix(cam.projectionMatrix, DoesRenderToTexture(cam));
            float     fov = cam.fieldOfView;
            HairWorksIntegration.hwSetViewProjection(ref V, ref P, fov);
            HairLight.AssignLightData();

            if (!s_cameras.Contains(cam))
            {
                cam.AddCommandBuffer(s_timing, s_command_buffer);
                s_cameras.Add(cam);
            }
        }

        HairWorksIntegration.hwBeginScene();
    }
    public static void Render(Camera CameraToAdd, HairInstance instance)
    {
        if (CmdBuffer_HairRender == null)
        {
            CmdBuffer_HairRender      = new CommandBuffer();
            CmdBuffer_HairRender.name = "Hair";
            CmdBuffer_HairRender.IssuePluginEvent(hwi.hwGetRenderEventFunc(), 0);
        }

        if (!HairWorksEnabled)
        {
            return;
        }

        if (CameraToAdd != null)
        {
            CameraEvent s_timing;

            if (IsDeferred(CameraToAdd))
            {
                s_timing = CameraEvent.BeforeImageEffects;
            }
            else
            {
                s_timing = CameraEvent.AfterImageEffectsOpaque;
            }

            Matrix4x4 V   = CameraToAdd.worldToCameraMatrix;
            Matrix4x4 P   = GL.GetGPUProjectionMatrix(CameraToAdd.projectionMatrix, DoesRenderToTexture(CameraToAdd));
            float     fov = CameraToAdd.fieldOfView;
            hwi.hwSetViewProjection(ref V, ref P, fov);
            HairLight.AssignLightData();

            if (!s_cameras.Contains(CameraToAdd))
            {
                CameraToAdd.AddCommandBuffer(s_timing, CmdBuffer_HairRender);
                s_cameras.Add(CameraToAdd);
            }
        }

        hwi.hwBeginScene();

        instance.Render();

        hwi.hwEndScene();
    }
    static void BeginRender()
    {
        if (s_command_buffer == null)
        {
            s_command_buffer      = new CommandBuffer();
            s_command_buffer.name = "Hair";
            s_command_buffer.IssuePluginEvent(HairWorksIntegration.hwGetRenderEventFunc(), 0);
        }
        var  cam      = Camera.current;
        bool goodToGo = false;

                #if UNITY_EDITOR
        if (UnityEditor.EditorApplication.isPlaying)
        {
            goodToGo = cam.CompareTag("MainCamera");
        }
        else
        {
            goodToGo = cam.CompareTag("Untagged");
        }
                #else
        goodToGo = cam.CompareTag("MainCamera");
                #endif
        if (cam != null && goodToGo)
        {
            Matrix4x4 V   = cam.worldToCameraMatrix;
            Matrix4x4 P   = GL.GetGPUProjectionMatrix(cam.projectionMatrix, DoesRenderToTexture(cam));
            float     fov = cam.fieldOfView;
            HairWorksIntegration.hwSetViewProjection(ref V, ref P, fov);
            HairLight.AssignLightData();

            if (!s_cameras.Contains(cam))
            {
                cam.AddCommandBuffer(s_timing, s_command_buffer);
                s_cameras.Add(cam);
            }
        }
        //foreach (HairLight hLight in HairLight.GetInstances()) {
        //if (Camera.current == Camera.main)
        //hLight.RenderShadowDepth (Camera.main);
        //}
        HairWorksIntegration.hwBeginScene();
    }