本文整理汇总了C#中Effect.GetConstantBufferByName方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.GetConstantBufferByName方法的具体用法?C# Effect.GetConstantBufferByName怎么用?C# Effect.GetConstantBufferByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Effect
的用法示例。
在下文中一共展示了Effect.GetConstantBufferByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Creates a "default parameter", such as World, View, Projection Matrices,
/// light direction, positionV3, ambient Color and so on.
/// </summary>
/// <param name="type">The type of the parameter to create.</param>
/// <param name="effect">A reference of the effect instance.</param>
/// <returns>An istance of EffectParameter containg all the needed information
/// to correctly set and update this value into the shader.</returns>
public static InstanceParameter Create(InstanceVariable type, Effect effect)
{
string varName = string.Empty;
dynamic eV = null;
UpdateInstanceParameter update = null;
VerboseEvent.InstanceParameterCreation.Log(type.ToString());
switch (type)
{
case InstanceVariable.ObjectWorld:
varName = ParamHandles.Matrices.World;
eV = effect.GetVariableByName(varName).AsMatrix();
update = (fxParam, rObject) => MatrixUpdate(fxParam.EffectVariable, rObject.World);
break;
case InstanceVariable.LightAmbient:
varName = ParamHandles.Color4s.LightAmbient;
eV = effect.GetVariableByName(varName).AsVector();
update =
(fxParam, rObject) =>
Color44Update(fxParam.EffectVariable,
((IColorMaterial)rObject.Material).AmbientColor);
break;
case InstanceVariable.Diffuse:
varName = ParamHandles.Color4s.MaterialDiffuse;
eV = effect.GetVariableByName(varName).AsVector();
update =
(fxParam, rObject) =>
Color44Update(fxParam.EffectVariable,
((IColorMaterial)rObject.Material).DiffuseColor);
break;
case InstanceVariable.Ambient:
varName = ParamHandles.Color4s.MaterialAmbient;
eV = effect.GetVariableByName(varName).AsVector();
update =
(fxParam, rObject) => Color44Update(fxParam.EffectVariable, ((IColorMaterial)rObject.Material).AmbientColor);
break;
case InstanceVariable.Specular:
varName = ParamHandles.Color4s.MaterialSpecular;
eV = effect.GetVariableByName(varName).AsVector();
update =
(fxParam, rObject) =>
Color44Update(fxParam.EffectVariable,
((IColorMaterial)rObject.Material).SpecularColor);
break;
case InstanceVariable.DiffuseMap:
varName = ParamHandles.Textures.DiffuseMap;
eV = effect.GetVariableByName(varName).AsResource();
update=(fxParam, rObject) =>
ResourceUpdate(fxParam.EffectVariable,
((IDiffuseMap)rObject).DiffuseMapResource);
break;
case InstanceVariable.AmbientCoefficient:
varName = ParamHandles.Color4s.MaterialkA;
eV = effect.GetVariableByName(varName).AsScalar();
update = (fxParam, rObject) => FloatUpdate(fxParam.EffectVariable, ((IColorMaterial)rObject.Material).AmbientCoefficient);
break;
case InstanceVariable.DiffuseCoefficient:
varName = ParamHandles.Color4s.MaterialkD;
eV = effect.GetVariableByName(varName).AsScalar();
update = (fxParam, rObject) => FloatUpdate(fxParam.EffectVariable, ((IColorMaterial)rObject.Material).AmbientCoefficient);
break;
case InstanceVariable.MaterialBuffer:
varName = ParamHandles.CBuffers.MaterialBuffer;
eV = effect.GetConstantBufferByName(varName).AsConstantBuffer();
update = (fxParam, rObject) => BufferUpdate(fxParam.EffectVariable, MaterialBuffer.FromMaterial((ShaderMaterial)rObject.Material));
break;
}
return new InstanceParameter(varName, type, effect, eV, update);
}