Пример #1
0
        void EncodeTextSDF(bgfx.Encoder *encoder, ushort viewId, ref MeshBGFX mesh, ref float4x4 tx,
                           ref TextSDFMaterialBGFX mat, int startIndex, int indexCount, uint depth, byte flipCulling)
        {
            bgfx.set_state(mat.state, 0);

            fixed(float4x4 *p = &tx)
            bgfx.encoder_set_transform(encoder, p, 1);

            mesh.SetForSubmit(encoder, startIndex, indexCount);
            // material uniforms setup
            fixed(TextSDFMaterialBGFX *pmat = &mat)
            {
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_FaceColor, &pmat->faceColor, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_ClipRect, &pmat->clipRect, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_MiscP, &pmat->miscP, 1);
#if false
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_TexDimScale, &pmat->texDimScale, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_OutlineColor, &pmat->outlineColor, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_OutlineP, &pmat->outlineP, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_UnderlayColor, &pmat->underlayColor, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_UnderlayP, &pmat->underlayP, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_WeightAndMaskSoftness, &pmat->weightAndMaskSoftness, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_ScaleRatio, &pmat->scaleRatio, 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_ScreenParams, &pmat->screenParams, 1);

                var txinv = math.inverse(tx);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_WorldSpaceCameraPos, UnsafeUtility.AddressOf(ref txinv), 1);
                bgfx.encoder_set_uniform(encoder, m_TextSDFShader.u_invModel0, UnsafeUtility.AddressOf(ref txinv), 1);
#endif
            }

            bgfx.encoder_set_texture(encoder, 0, m_TextSDFShader.u_MainTex, mat.texAtlas, UInt32.MaxValue);
            bgfx.encoder_submit(encoder, viewId, m_TextSDFShader.m_prog, depth, (byte)bgfx.DiscardFlags.All);
        }
Пример #2
0
 void SubmitTextSDFDirect(ushort viewId, ref MeshBGFX mesh, ref float4x4 tx, ref TextSDFMaterialBGFX mat,
                          int startIndex, int indexCount, uint depth, byte flipCulling)
 {
     bgfx.Encoder *encoder = bgfx.encoder_begin(false);
     EncodeTextSDF(encoder, viewId, ref mesh, ref tx, ref mat, startIndex, indexCount, depth, flipCulling);
     bgfx.encoder_end(encoder);
 }