public override void GenerateShader(MaterialGeneratorContext context)
        {
            var shaderSource = new ShaderMixinSource();

            shaderSource.Mixins.Add(new ShaderClassSource("MaterialSurfaceSubsurfaceScatteringShading"));

            TranslucencyMap.ClampFloat(0.0f, 1.0f);
            context.SetStream(ScatteringStrengthStream.Stream, TranslucencyMap, MaterialKeys.ScatteringStrengthMap, MaterialKeys.ScatteringStrengthValue);

            // TODO: Generate a hash with the scattering kernel and scattering width!

            var parameters = context.MaterialPass.Parameters;

            parameters.Set(Stride.Rendering.Materials.MaterialSurfaceSubsurfaceScatteringShadingKeys.Translucency, Translucency);
            parameters.Set(Stride.Rendering.Materials.MaterialSurfaceSubsurfaceScatteringShadingKeys.ScatteringWidth, ScatteringWidth);

            // Generate and set the scattering profile:
            shaderSource.AddComposition("scatteringProfileFunction", ProfileFunction.Generate(context));

            // Generate and set the scattering kernel:
            Vector4[] scatteringKernel = KernelFunction.Generate();
            parameters.Set(Stride.Rendering.Materials.MaterialSurfaceSubsurfaceScatteringShadingKeys.ScatteringKernel, scatteringKernel);

            /*
             * {
             *  Game game = Services.GetSafeServiceAs<Game>();
             *  SubsurfaceScatteringSettings settings = game.Settings.Configurations.Get<SubsurfaceScatteringSettings>();
             *  //SubsurfaceScatteringSettings settings = services.GetSafeServiceAs<SubsurfaceScatteringSettings>();  // TODO: Query the settings like this once the system is ready.
             * }
             */

            var shaderBuilder = context.AddShading(this);

            shaderBuilder.LightDependentSurface = shaderSource;
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ScatteringWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ Translucency.GetHashCode();
         hashCode = (hashCode * 397) ^ TranslucencyMap.GetHashCode();
         hashCode = (hashCode * 397) ^ ProfileFunction.GetHashCode();
         hashCode = (hashCode * 397) ^ KernelFunction.GetHashCode();
         return(hashCode);
     }
 }
 protected bool Equals(MaterialSubsurfaceScatteringFeature other)
 {
     return(ScatteringWidth.Equals(other.ScatteringWidth) && Translucency.Equals(other.Translucency) && TranslucencyMap.Equals(other.TranslucencyMap) && ProfileFunction.Equals(other.ProfileFunction) && KernelFunction.Equals(other.KernelFunction));
 }