private unsafe static void EncodeMappedLight(bgfx.Encoder *encoder, ref MappedLightBGFX light, ref LitShader.MappedLight shader, byte samplerOffset, float4 viewPosOrDir)
        {
            fixed(float4x4 *p = &light.projection)
            bgfx.encoder_set_uniform(encoder, shader.m_uniformMatrix, p, 1);

            fixed(float4 *p = &light.color_invrangesqr)
            bgfx.encoder_set_uniform(encoder, shader.m_uniformColorIVR, p, 1);

            fixed(float4 *p = &light.mask)
            bgfx.encoder_set_uniform(encoder, shader.m_uniformLightMask, p, 1);

            bgfx.encoder_set_uniform(encoder, shader.m_uniformViewPosOrDir, &viewPosOrDir, 1);
            bgfx.encoder_set_texture(encoder, (byte)(6 + samplerOffset), shader.m_samplerShadow, light.shadowMap, UInt32.MaxValue);
        }