} = new ComputeColor(new Color4(1.0f, 0.37f, 0.3f, 1.0f)); // Default falloff for skin. public ShaderSource Generate(MaterialGeneratorContext context) { var shaderSource = new ShaderMixinSource(); MaterialComputeColorKeys materialComputeColorKeys = new MaterialComputeColorKeys(FalloffTexture, FalloffValue, DefaultProfileColor); // Add the shader for computing the transmittance using the custom scattering profile: if (FalloffMap is ComputeTextureColor || FalloffMap is ComputeBinaryColor || FalloffMap is ComputeShaderClassColor || FalloffMap is ComputeVertexStreamColor) { var computeColorSource = FalloffMap.GenerateShaderSource(context, materialComputeColorKeys); shaderSource.AddComposition("FalloffMap", computeColorSource); // Use the expensive pixel shader because the scattering falloff can vary per pixel because we're using a texture: shaderSource.Mixins.Add(new ShaderClassSource("MaterialSubsurfaceScatteringScatteringProfileCustomVarying")); } else { Vector3 falloff = new Vector3(1.0f); ComputeColor falloffComputeColor = FalloffMap as ComputeColor; if (falloffComputeColor != null) { falloff.X = falloffComputeColor.Value.R; falloff.Y = falloffComputeColor.Value.G; falloff.Z = falloffComputeColor.Value.B; } ComputeFloat4 falloffComputeFloat4 = FalloffMap as ComputeFloat4; if (falloffComputeFloat4 != null) { falloff.X = falloffComputeFloat4.Value.X; falloff.Y = falloffComputeFloat4.Value.Y; falloff.Z = falloffComputeFloat4.Value.Z; } // Use the precomputed pixel shader because the scattering falloff is constant across pixels because we're using a texture: Vector4[] scatteringProfile = SubsurfaceScatteringKernelGenerator.CalculateTransmittanceProfile(falloff); // Applied during forward pass. context.MaterialPass.Parameters.Set(MaterialSubsurfaceScatteringScatteringProfileCustomUniformKeys.ScatteringProfile, scatteringProfile); shaderSource.Mixins.Add(new ShaderClassSource("MaterialSubsurfaceScatteringScatteringProfileCustomUniform")); } return(shaderSource); }
} = new Color3(0.48f, 0.41f, 0.28f); // Default strength for skin. public Vector4[] Generate() { return(SubsurfaceScatteringKernelGenerator.CalculateScatteringKernel(SubsurfaceScatteringSettings.SamplesPerScatteringKernel2, Strength, Falloff)); }