public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource classSource) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } // Blend stream is not part of the stream used if (stream != MaterialBlendLayer.BlendStream) { GetContextPerStage(stage).Streams.Add(stream); } string channel; switch (streamType) { case MaterialStreamType.Float: channel = "r"; break; case MaterialStreamType.Float2: channel = "rg"; break; case MaterialStreamType.Float3: channel = "rgb"; break; case MaterialStreamType.Float4: channel = "rgba"; break; default: throw new NotSupportedException("StreamType [{0}] is not supported".ToFormat(streamType)); } var mixin = new ShaderMixinSource(); mixin.Mixins.Add(new ShaderClassSource("MaterialSurfaceSetStreamFromComputeColor", stream, channel)); mixin.AddComposition("computeColorSource", classSource); GetContextPerStage(stage).ShaderSources.Add(mixin); }
public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource shaderSource) { currentLayerContext.SetStream(stage, stream, streamType, shaderSource); }
public void SetStream(MaterialShaderStage stage, string stream, MaterialStreamType streamType, ShaderSource classSource) { if (stream == null) throw new ArgumentNullException(nameof(stream)); // Blend stream is not part of the stream used if (stream != MaterialBlendLayer.BlendStream) { GetContextPerStage(stage).Streams.Add(stream); } string channel; switch (streamType) { case MaterialStreamType.Float: channel = "r"; break; case MaterialStreamType.Float2: channel = "rg"; break; case MaterialStreamType.Float3: channel = "rgb"; break; case MaterialStreamType.Float4: channel = "rgba"; break; default: throw new NotSupportedException("StreamType [{0}] is not supported".ToFormat(streamType)); } var mixin = new ShaderMixinSource(); mixin.Mixins.Add(new ShaderClassSource("MaterialSurfaceSetStreamFromComputeColor", stream, channel)); mixin.AddComposition("computeColorSource", classSource); GetContextPerStage(stage).ShaderSources.Add(mixin); }