本文整理汇总了C#中ShaderMixinSource.AddCompositionToArray方法的典型用法代码示例。如果您正苦于以下问题:C# ShaderMixinSource.AddCompositionToArray方法的具体用法?C# ShaderMixinSource.AddCompositionToArray怎么用?C# ShaderMixinSource.AddCompositionToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderMixinSource
的用法示例。
在下文中一共展示了ShaderMixinSource.AddCompositionToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Generate
private void Generate(MaterialShaderStage stage, MaterialGeneratorContext context)
{
if (!context.HasSurfaceShaders(stage))
{
return;
}
// Blend setup for this layer
context.SetStream(stage, BlendStream, BlendMap, MaterialKeys.BlendMap, MaterialKeys.BlendValue);
// Generate a dynamic shader name
// Create a mixin
var shaderMixinSource = new ShaderMixinSource();
shaderMixinSource.Mixins.Add(new ShaderClassSource("MaterialSurfaceStreamsBlend"));
// Add all streams
foreach (var stream in context.Streams[stage])
{
shaderMixinSource.AddCompositionToArray("blends", context.GetStreamBlendShaderSource(stream));
}
var materialBlendLayerMixin = context.GenerateSurfaceShader(stage);
// Add the shader to the mixin
shaderMixinSource.AddComposition("layer", materialBlendLayerMixin);
context.ResetSurfaceShaders(stage);
context.AddSurfaceShader(stage, shaderMixinSource);
}