示例#1
0
        unsafe private void NotifyMaterialSetup(uint pass_id, MaterialPtr mat)
        {
            // Prepare the fragment params offsets
            switch (pass_id)
            {
            //case 994: // rt_lum4
            case 993:     // rt_lum3
            case 992:     // rt_lum2
            case 991:     // rt_lum1
            case 990:     // rt_lum0
                break;

            case 800:     // rt_brightpass
                break;

            case 701:     // rt_bloom1
            {
                // horizontal bloom
                mat.Load();
                GpuProgramParametersSharedPtr fparams =
                    mat.GetBestTechnique().GetPass(0).GetFragmentProgramParameters();
                String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                fixed(float *p_mBloomTexOffsetsHorz = &mBloomTexOffsetsHorz[0, 0])
                {
                    fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsHorz, 15);
                }

                fixed(float *p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                {
                    fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                }

                break;
            }

            case 700:     // rt_bloom0
            {
                // vertical bloom
                mat.Load();
                GpuProgramParametersSharedPtr fparams =
                    mat.GetTechnique(0).GetPass(0).GetFragmentProgramParameters();
                String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                fixed(float *p_mBloomTexOffsetsVert = &mBloomTexOffsetsVert[0, 0])
                {
                    fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsVert, 15);
                }

                fixed(float *p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                {
                    fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                }

                break;
            }
            }
        }
示例#2
0
        private void BindGpuProgramParameters(GpuProgramType type, Miyagi.Common.Resources.GpuProgram gpuProg)
        {
            if (gpuProg.NamedConstants.Count > 0)
            {
                using (GpuProgramParametersSharedPtr gpuParas = type == GpuProgramType.GPT_FRAGMENT_PROGRAM
                                                                                                                                        ? this.MogreRenderManager.Pass.GetFragmentProgramParameters()
                                                                                                                                        : this.MogreRenderManager.Pass.GetVertexProgramParameters())
                {
                    foreach (KeyValuePair <string, object> kvp in gpuProg.NamedConstants)
                    {
                        object o = kvp.Value;

                        if (o is ColourValue)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (ColourValue)o);
                        }
                        else if (o is int)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (int)o);
                        }
                        else if (o is float)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (float)o);
                        }
                        else if (o is Matrix4)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Matrix4)o);
                        }
                        else if (o is Vector3)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Vector3)o);
                        }
                        else if (o is Vector4)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Vector4)o);
                        }
                    }

                    this.renderSystem.BindGpuProgramParameters(type, gpuParas, (ushort)GpuParamVariability.GPV_ALL);
                }
            }
        }