当前位置: 首页>>代码示例>>C#>>正文


C# Cache.GetMaterialValue方法代码示例

本文整理汇总了C#中Cache.GetMaterialValue方法的典型用法代码示例。如果您正苦于以下问题:C# Cache.GetMaterialValue方法的具体用法?C# Cache.GetMaterialValue怎么用?C# Cache.GetMaterialValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


在下文中一共展示了Cache.GetMaterialValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadPixelShaderParameters

        public void LoadPixelShaderParameters(Cache.VarEquip material, int materialMeshOffset)
        {
            TextureManager texMan = GlobalRenderSettings.Instance.TextureManager;

            int numConstants = this.PixelShaderInfo.ConstantDescriptions.Count;
            for (var i = 0; i < numConstants; i++)
            {
                var desc = this.PixelShaderInfo.ConstantDescriptions[i];
                var handle = this.PixelShaderInfo.ConstantHandles[i];

                if (desc.RegisterSet == RegisterSet.Sampler)
                {
                    for (var s = 0; s < paramData.NumSamplers; s++)
                    {
                        var sampler = paramData.Samplers[s];
                        if (sampler.Name == desc.Name)
                        {
                            BaseTexture tex = null;
                            for (var t = 0; t < sampler.StringTable.Count; t++)
                            {
                                if (sampler.Name == "lightDiffuseMap")
                                {
                                    tex = texMan.LightDiffuseMap;
                                }
                                else
                                {
                                    tex = texMan.GetByName(sampler.StringTable[t]);
                                }

                                if (tex != null)
                                {
                                    device.SetTexture(desc.RegisterIndex, tex);
                                    device.SetSamplerState(desc.RegisterIndex, SamplerState.MinFilter, TextureFilter.Anisotropic);
                                    device.SetSamplerState(desc.RegisterIndex, SamplerState.MagFilter, TextureFilter.Anisotropic);
                                    device.SetSamplerState(desc.RegisterIndex, SamplerState.MipFilter, TextureFilter.Anisotropic);
                                    break;
                                }
                            }
                            if (tex == null)
                            {
                                throw new InvalidOperationException("Unable to load texture " + sampler.StringTable[0]);
                            }
                        }
                    }
                    continue;
                }

                SetConstantValueDelegate del;
                if (pxlSetters.TryGetValue(desc.Name, out del))
                {
                    del(this.PixelShader.Function.ConstantTable, device, handle);
                }
            }

            // Set the defaults specified in the pixel shader bytecode
            this.PixelShader.Function.ConstantTable.SetDefaults(device);

            // Set the defaults specified in the PRAM data
            foreach (ParameterData pdata in paramData.Parameters)
            {
                if (!pdata.IsPixelShaderParameter) { continue; }

                Vector4 val = pdata.Defaults;
                if (material != null)
                {
                    switch (pdata.Name)
                    {
                        case "modulateColor":
                            var actor = GlobalRenderSettings.Instance.Actor;
                            if (actor != null)
                            {
                                if (paramData.Samplers.Find(x => x.Name.Equals("lightToneMap")) != null)
                                {
                                    Color3 color = ColorHelper.GetSkinTone(actor.BaseModelFolder, actor.C22);
                                    val.X = color.Red;
                                    val.Y = color.Green;
                                    val.Z = color.Blue;
                                }
                                else if (paramData.Parameters.Find(x => x.Name.Equals("velvetParam")) != null)
                                {
                                    Color3 color = ColorHelper.GetHairColor(actor.BaseModelFolder, actor.C21);
                                    val.X = color.Red;
                                    val.Y = color.Green;
                                    val.Z = color.Blue;
                                }
                            }
                            break;
                        case "diffuseColor":
                            val.X = material.GetMaterialValue(0, materialMeshOffset, val.X);
                            val.Y = material.GetMaterialValue(1, materialMeshOffset, val.Y);
                            val.Z = material.GetMaterialValue(2, materialMeshOffset, val.Z);
                            break;
                        case "multiDiffuseColor":
                            val.X = material.GetMaterialValue(3, materialMeshOffset, val.X);
                            val.Y = material.GetMaterialValue(4, materialMeshOffset, val.Y);
                            val.Z = material.GetMaterialValue(5, materialMeshOffset, val.Z);
                            val.W = material.GetMaterialValue(6, materialMeshOffset, val.W);
                            break;
                        /*case "specularColor":
                            val.X = material.GetMaterialValue(7, materialMeshOffset, val.X);
//.........这里部分代码省略.........
开发者ID:nohbdy,项目名称:ffxivmodelviewer,代码行数:101,代码来源:ShaderManager.cs


注:本文中的Cache.GetMaterialValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。