本文整理汇总了C#中ShaderMixinSource.AddMacro方法的典型用法代码示例。如果您正苦于以下问题:C# ShaderMixinSource.AddMacro方法的具体用法?C# ShaderMixinSource.AddMacro怎么用?C# ShaderMixinSource.AddMacro使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderMixinSource
的用法示例。
在下文中一共展示了ShaderMixinSource.AddMacro方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "A");
context.Mixin(mixin, "B");
if (context.GetParam(TestParameters.param1))
{
context.Mixin(mixin, "C");
mixin.AddMacro("param2", context.GetParam(TestParameters.param2));
{
var __mixinToCompose__ = "X";
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "x", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
else
{
context.Mixin(mixin, "D");
mixin.AddMacro("Test", context.GetParam(TestParameters.param3));
{
var __mixinToCompose__ = "Y";
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "y", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
示例2: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
mixin.AddMacro("ThreadNumberX", context.GetParam(ComputeEffectShaderKeys.ThreadNumbers).X);
mixin.AddMacro("ThreadNumberY", context.GetParam(ComputeEffectShaderKeys.ThreadNumbers).Y);
mixin.AddMacro("ThreadNumberZ", context.GetParam(ComputeEffectShaderKeys.ThreadNumbers).Z);
context.Mixin(mixin, "ComputeShaderBase");
context.Mixin(mixin, context.GetParam(ComputeEffectShaderKeys.ComputeShaderName));
}
示例3: TestMacros
public void TestMacros()
{
// test that macros are correctly used
var baseMixin = new ShaderMixinSource();
baseMixin.AddMacro("SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D", 1);
baseMixin.Macros.Add(new ShaderMacro("MACRO_TEST", "int"));
baseMixin.Mixins.Add(new ShaderClassSource("TestMacros"));
var macros0 = new ShaderMixinSource();
macros0.Mixins.Add(new ShaderClassSource("MacroTest"));
baseMixin.Compositions.Add("macros0", macros0);
var macros1 = new ShaderMixinSource();
macros1.Mixins.Add(new ShaderClassSource("MacroTest"));
macros1.Macros.Add(new ShaderMacro("MACRO_TEST", "float"));
baseMixin.Compositions.Add("macros1", macros1);
var macros2 = new ShaderMixinSource();
macros2.Mixins.Add(new ShaderClassSource("MacroTest"));
macros2.Macros.Add(new ShaderMacro("MACRO_TEST", "float4"));
baseMixin.Compositions.Add("macros2", macros2);
var parsingResult = shaderMixinParser.Parse(baseMixin, baseMixin.Macros.ToArray());
Assert.IsFalse(parsingResult.HasErrors);
var cBufferVar = parsingResult.Shader.Declarations.OfType<ConstantBuffer>().First(x => x.Name == "Globals").Members.OfType<Variable>().ToList();
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "int"));
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "float"));
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "float4"));
// test clash when reloading
var baseMixin2 = new ShaderMixinSource();
baseMixin2.AddMacro("SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D", 1);
baseMixin2.Macros.Add(new ShaderMacro("MACRO_TEST", "int"));
baseMixin2.Mixins.Add(new ShaderClassSource("TestMacros"));
var macros3 = new ShaderMixinSource();
macros3.Mixins.Add(new ShaderClassSource("MacroTest"));
baseMixin2.Compositions.Add("macros0", macros3);
var macros4 = new ShaderMixinSource();
macros4.Mixins.Add(new ShaderClassSource("MacroTest"));
macros4.Macros.Add(new ShaderMacro("MACRO_TEST", "uint4"));
baseMixin2.Compositions.Add("macros1", macros4);
var macros5 = new ShaderMixinSource();
macros5.Mixins.Add(new ShaderClassSource("MacroTest"));
macros5.Macros.Add(new ShaderMacro("MACRO_TEST", "float4"));
baseMixin2.Compositions.Add("macros2", macros5);
var parsingResult2 = shaderMixinParser.Parse(baseMixin2, baseMixin2.Macros.ToArray());
Assert.IsFalse(parsingResult.HasErrors);
var cBufferVar2 = parsingResult2.Shader.Declarations.OfType<ConstantBuffer>().First(x => x.Name == "Globals").Members.OfType<Variable>().ToList();
Assert.AreEqual(1, cBufferVar2.Count(x => x.Type.Name.Text == "int"));
Assert.AreEqual(1, cBufferVar2.Count(x => x.Type.Name.Text == "uint4"));
Assert.AreEqual(1, cBufferVar2.Count(x => x.Type.Name.Text == "float4"));
}
示例4: TestMacrosArray
public void TestMacrosArray()
{
// test that macros are correctly used through an array
var baseMixin = new ShaderMixinSource();
baseMixin.AddMacro("SILICONSTUDIO_XENKO_GRAPHICS_API_DIRECT3D", 1);
baseMixin.Macros.Add(new ShaderMacro("MACRO_TEST", "int"));
baseMixin.Mixins.Add(new ShaderClassSource("TestMacrosArray"));
var compositionArray = new ShaderArraySource();
var macros0 = new ShaderMixinSource();
macros0.Mixins.Add(new ShaderClassSource("MacroTest"));
compositionArray.Add(macros0);
var macros1 = new ShaderMixinSource();
macros1.Mixins.Add(new ShaderClassSource("MacroTest"));
macros1.Macros.Add(new ShaderMacro("MACRO_TEST", "float"));
compositionArray.Add(macros1);
var macros2 = new ShaderMixinSource();
macros2.Mixins.Add(new ShaderClassSource("MacroTest"));
macros2.Macros.Add(new ShaderMacro("MACRO_TEST", "float4"));
compositionArray.Add(macros2);
baseMixin.Compositions.Add("macrosArray", compositionArray);
var parsingResult = shaderMixinParser.Parse(baseMixin, baseMixin.Macros.ToArray());
Assert.IsFalse(parsingResult.HasErrors);
var cBufferVar = parsingResult.Shader.Declarations.OfType<ConstantBuffer>().First(x => x.Name == "Globals").Members.OfType<Variable>().ToList();
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "int"));
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "float"));
Assert.AreEqual(1, cBufferVar.Count(x => x.Type.Name.Text == "float4"));
}
示例5: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "ShaderBase");
context.Mixin(mixin, "ShadingBase");
var extensionPreVertexStageSurfaceShaders = context.GetParam(MaterialKeys.VertexStageSurfaceShaders);
if (extensionPreVertexStageSurfaceShaders != null)
{
context.Mixin(mixin, "MaterialSurfaceVertexStageCompositor");
{
var __mixinToCompose__ = (extensionPreVertexStageSurfaceShaders);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "materialVertexStage", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
{
var __mixinToCompose__ = context.GetParam(MaterialKeys.VertexStageStreamInitializer);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "streamInitializerVertexStage", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
context.Mixin(mixin, "TransformationBase");
context.Mixin(mixin, "NormalStream");
context.Mixin(mixin, "TransformationWAndVP");
if (context.GetParam(MaterialKeys.HasNormalMap))
{
context.Mixin(mixin, "NormalFromNormalMapping");
}
else
{
context.Mixin(mixin, "NormalFromMesh");
}
if (context.GetParam(MaterialKeys.HasSkinningPosition))
{
mixin.AddMacro("SkinningMaxBones", context.GetParam(MaterialKeys.SkinningMaxBones));
context.Mixin(mixin, "TransformationSkinning");
if (context.GetParam(MaterialKeys.HasSkinningNormal))
{
context.Mixin(mixin, "NormalMeshSkinning");
}
if (context.GetParam(MaterialKeys.HasSkinningTangent))
{
context.Mixin(mixin, "TangentMeshSkinning");
}
if (context.GetParam(MaterialKeys.HasSkinningNormal))
{
if (context.GetParam(MaterialKeys.HasNormalMap))
{
context.Mixin(mixin, "NormalVSSkinningNormalMapping");
}
else
{
context.Mixin(mixin, "NormalVSSkinningFromMesh");
}
}
}
var extensionTessellationShader = context.GetParam(MaterialKeys.TessellationShader);
if (extensionTessellationShader != null)
{
context.Mixin(mixin, (extensionTessellationShader));
var extensionDomainStageSurfaceShaders = context.GetParam(MaterialKeys.DomainStageSurfaceShaders);
if (extensionDomainStageSurfaceShaders != null)
{
context.Mixin(mixin, "MaterialSurfaceDomainStageCompositor");
{
var __mixinToCompose__ = (extensionDomainStageSurfaceShaders);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "materialDomainStage", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
{
var __mixinToCompose__ = context.GetParam(MaterialKeys.DomainStageStreamInitializer);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "streamInitializerDomainStage", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
var extensionPostVertexStage = context.GetParam(XenkoEffectBaseKeys.ExtensionPostVertexStageShader);
if (extensionPostVertexStage != null)
{
context.Mixin(mixin, (extensionPostVertexStage));
}
}
示例6: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
mixin.AddMacro("FXAA_GREEN_AS_LUMA", context.GetParam(FXAAEffect.GreenAsLumaKey));
mixin.AddMacro("FXAA_QUALITY__PRESET", context.GetParam(FXAAEffect.QualityKey));
context.Mixin(mixin, "FXAAShader");
}
示例7: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "ShaderBase");
context.Mixin(mixin, "TransformationWAndVP");
mixin.AddMacro("MAX_VERTEX_COUNT", 9);
context.Mixin(mixin, "CameraCube");
context.Mixin(mixin, "AlbedoFlatShading");
if (context.GetParam(MaterialParameters.AlbedoDiffuse) != null)
{
var __mixinToCompose__ = context.GetParam(MaterialParameters.AlbedoDiffuse);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "albedoDiffuse", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
示例8: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
mixin.AddMacro("UsesSoftEdge", context.GetParam(ParticleBaseKeys.UsesSoftEdge));
context.Mixin(mixin, "ParticleBase");
}