本文整理汇总了C#中ShaderMixinSource类的典型用法代码示例。如果您正苦于以下问题:C# ShaderMixinSource类的具体用法?C# ShaderMixinSource怎么用?C# ShaderMixinSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShaderMixinSource类属于命名空间,在下文中一共展示了ShaderMixinSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "A");
context.Mixin(mixin, "B");
context.Mixin(mixin, "C");
context.Mixin(mixin, "ChildMixin");
}
示例2: Visit
public void Visit(MaterialGeneratorContext context)
{
var alpha = Alpha ?? new ComputeFloat(0.5f);
var tint = Tint ?? new ComputeColor(Color.White);
// Use pre-multiplied alpha to support both additive and alpha blending
var blendDesc = new BlendStateDescription(Blend.One, Blend.InverseSourceAlpha);
context.Material.HasTransparency = true;
context.Parameters.Set(Effect.BlendStateKey, BlendState.NewFake(blendDesc));
var alphaColor = alpha.GenerateShaderSource(context, new MaterialComputeColorKeys(MaterialKeys.DiffuseSpecularAlphaBlendMap, MaterialKeys.DiffuseSpecularAlphaBlendValue, Color.White));
var mixin = new ShaderMixinSource();
mixin.Mixins.Add(new ShaderClassSource("ComputeColorMaterialAlphaBlend"));
mixin.AddComposition("color", alphaColor);
context.SetStream(MaterialShaderStage.Pixel, AlphaBlendStream.Stream, MaterialStreamType.Float2, mixin);
context.SetStream(AlphaBlendColorStream.Stream, tint, MaterialKeys.AlphaBlendColorMap, MaterialKeys.AlphaBlendColorValue, Color.White);
if (!context.Tags.Get(HasFinalCallback))
{
context.Tags.Set(HasFinalCallback, true);
context.AddFinalCallback(MaterialShaderStage.Pixel, AddDiffuseSpecularAlphaBlendColor);
}
}
示例3: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
var directLightGroups = context.GetParam(LightingKeys.DirectLightGroups);
if (directLightGroups != null)
{
foreach(var directLightGroup in directLightGroups)
{
{
var __mixinToCompose__ = (directLightGroup);
var __subMixin = new ShaderMixinSource();
context.PushCompositionArray(mixin, "directLightGroups", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
var environmentLights = context.GetParam(LightingKeys.EnvironmentLights);
if (environmentLights != null)
{
foreach(var environmentLight in environmentLights)
{
{
var __mixinToCompose__ = (environmentLight);
var __subMixin = new ShaderMixinSource();
context.PushCompositionArray(mixin, "environmentLights", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
}
示例4: 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();
}
}
}
示例5: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "A");
context.Mixin(mixin, "B");
context.Mixin(mixin, "C");
int x = 1;
foreach(var ____1 in context.GetParam(TestParameters.subParameters))
{
context.PushParameters(____1);
if (context.GetParam(SubParameters.param1))
{
context.Mixin(mixin, "C" + x);
}
x++;
context.PopParameters();
}
{
context.PushParameters(context.GetParam(TestParameters.subParam1));
if (context.GetParam(SubParameters.param2) == 1)
{
context.Mixin(mixin, "D");
}
context.PopParameters();
}
}
示例6: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "LightSkyboxShader");
if (context.GetParam(LightSkyboxShaderKeys.LightDiffuseColor) != null)
{
{
var __mixinToCompose__ = context.GetParam(LightSkyboxShaderKeys.LightDiffuseColor);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "lightDiffuseColor", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
if (context.GetParam(LightSkyboxShaderKeys.LightSpecularColor) != null)
{
{
var __mixinToCompose__ = context.GetParam(LightSkyboxShaderKeys.LightSpecularColor);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "lightSpecularColor", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
示例7: ComputeShaderSource
/// <summary>
/// Squash <see cref="ShaderSources"/> to a single ShaderSource (compatible with IComputeColor)
/// </summary>
/// <returns>The squashed <see cref="ShaderSource"/> or null if nothing to squash</returns>
public ShaderSource ComputeShaderSource()
{
if (ShaderSources.Count == 0)
{
return null;
}
ShaderSource result;
// If there is only a single op, don't generate a mixin
if (ShaderSources.Count == 1)
{
result = ShaderSources[0];
}
else
{
var mixin = new ShaderMixinSource();
result = mixin;
mixin.Mixins.Add(new ShaderClassSource("MaterialSurfaceArray"));
// Squash all operations into MaterialLayerArray
foreach (var operation in ShaderSources)
{
mixin.AddCompositionToArray("layers", operation);
}
}
return result;
}
示例8: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "A");
{
var __mixinToCompose__ = "ABCSubEffect";
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "SubCompute1", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
{
var __mixinToCompose__ = "ABCSubEffect";
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "SubCompute2", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
{
var __mixinToCompose__ = "ABCSubEffect";
var __subMixin = new ShaderMixinSource();
context.PushCompositionArray(mixin, "SubComputes", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
示例9: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "ParticleBaseEffect");
context.Mixin(mixin, "ParticleCustomShader");
if (context.GetParam(ParticleCustomShaderKeys.BaseColor) != null)
{
{
var __mixinToCompose__ = context.GetParam(ParticleCustomShaderKeys.BaseColor);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "baseColor", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
if (context.GetParam(ParticleCustomShaderKeys.BaseIntensity) != null)
{
{
var __mixinToCompose__ = context.GetParam(ParticleCustomShaderKeys.BaseIntensity);
var __subMixin = new ShaderMixinSource();
context.PushComposition(mixin, "baseIntensity", __subMixin);
context.Mixin(__subMixin, __mixinToCompose__);
context.PopComposition();
}
}
}
示例10: CompileAsync
private async Task<EffectBytecodeCompilerResult> CompileAsync(ShaderMixinSource mixinTree, CompilerParameters compilerParameters)
{
// Make sure we are connected
// TODO: Handle reconnections, etc...
await shaderCompilerConnected;
return await shaderCompilerTarget.Compile(mixinTree, compilerParameters);
}
示例11: 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));
}
示例12: 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"));
}
示例13: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "CustomShader");
if (context.ChildEffectName == "CustomSubEffect")
{
context.Mixin(mixin, "CustomSubEffect");
return;
}
}
示例14: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "ParadoxForwardShadingEffect");
if (context.GetParam(GameParameters.EnableOnflyTextureUVChange))
context.Mixin(mixin, "TransformationTextureUV");
if (context.GetParam(GameParameters.EnableBend))
context.Mixin(mixin, "TransformationBendWorld");
if (context.GetParam(GameParameters.EnableFog))
context.Mixin(mixin, "FogEffect");
}
示例15: Generate
public void Generate(ShaderMixinSource mixin, ShaderMixinContext context)
{
context.Mixin(mixin, "A");
context.Mixin(mixin, "B");
context.Mixin(mixin, "C");
if (context.ChildEffectName == "Test")
{
context.Mixin(mixin, "ChildClone");
return;
}
}