// ---------------- shadow map ----------------------------------------------------------------------------------------------------------------------
        public static unsafe void EncodeShadowMapMesh(RendererBGFXInstance *sys, bgfx.Encoder *encoder, ushort viewId, ref MeshBGFX mesh, ref float4x4 tx,
                                                      int startIndex, int indexCount, byte flipCulling, float4 bias)
        {
#if DEBUG
            float4 cd = GetShadowDebugColor(mesh.DebugIndex() + startIndex);
#endif
            mesh.SetForSubmit(encoder, startIndex, indexCount);
            EncodeShadowMap(sys, encoder, ref sys->m_shadowMapShader, viewId, ref tx, flipCulling, bias
#if DEBUG
                            , cd
#endif
                            );
        }
        public static unsafe void EncodeShadowMapSkinnedMesh(RendererBGFXInstance *sys, bgfx.Encoder *encoder, ushort viewId, ref MeshBGFX mesh, ref float4x4 tx,
                                                             int startIndex, int indexCount, byte flipCulling, float4 bias, float4x4[] boneMatrices)
        {
#if DEBUG
            float4 cd = GetShadowDebugColor(mesh.DebugIndex() + startIndex);
#endif
            mesh.SetForSubmit(encoder, startIndex, indexCount);
            fixed(float4x4 *p = boneMatrices)
            {
                bgfx.encoder_set_uniform(encoder, sys->m_skinnedMeshShadowMapShader.m_uniformBoneMatrices, p, (ushort)boneMatrices.Length);
            }

            EncodeShadowMap(sys, encoder, ref sys->m_skinnedMeshShadowMapShader.m_shadowMapShader, viewId, ref tx, flipCulling, bias
#if DEBUG
                            , cd
#endif
                            );
        }