本文整理汇总了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);
//.........这里部分代码省略.........