stride/samples/Particles/ParticlesSample/ParticlesSample.Game/Effects/ParticleCustomShader.sdsl

38 lines
1.5 KiB
Text
Raw Permalink Normal View History

2021-04-19 03:49:55 +00:00
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
2018-06-19 09:06:54 +00:00
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
// By inheriting the ParticleBase we inherit Texturing and the VSMain/PSMain methods, enough to draw a uniformly colored quad
shader ParticleCustomShader : ParticleBase
{
// -------------------------------------
// streams
// -------------------------------------
// This shader is settable by the user, and it's a binary tree made up from smaller shaders
compose ComputeColor baseColor;
// This shader is settable by the user, and it's a binary tree made up from smaller shaders
compose ComputeColor baseIntensity;
// Shading of the sprite - we override the base shader's Shading(), which only returns ColorScale
stage override float4 Shading()
{
// -----------------------------------------------
// Base particle color RGB
// -----------------------------------------------
float4 finalColor = base.Shading() * baseColor.Compute();
// -----------------------------------------------
// Base particle alpha
// -----------------------------------------------
finalColor.a = baseIntensity.Compute();
// Don't forget to premultiply the alpha
finalColor.rgb *= finalColor.aaa;
return finalColor;
}
};