private void AddMetalFlakesGlossiness(MaterialGeneratorContext context) { var surfaceToEyeDistance = LODDistance.GenerateShaderSource(context, new MaterialComputeColorKeys(MaterialKeys.GlossinessMap, MaterialKeys.GlossinessValue, Color.White)); // Metal Flakes Glossiness Feature context.UseStream(MaterialShaderStage.Pixel, "matGlossiness"); var baseGlossinessComputeColorMap = BasePaintGlossinessMap.GenerateShaderSource(context, new MaterialComputeColorKeys(MaterialKeys.GlossinessMap, MaterialKeys.GlossinessValue)); var mixinGlossiness = new ShaderMixinSource(); // Computes glossiness factor for the metal flakes layer (based on the eye to surface distance and the base glossiness value) mixinGlossiness.Mixins.Add(new ShaderClassSource("MaterialSurfaceGlossinessMapMetalFlakes", BasePaintGlossinessInvert)); mixinGlossiness.AddComposition("glossinessMap", baseGlossinessComputeColorMap); mixinGlossiness.AddComposition("surfaceToEyeDistanceFactor", surfaceToEyeDistance); context.AddShaderSource(MaterialShaderStage.Pixel, mixinGlossiness); }
private void AddMetalFlakesDiffuse(MaterialGeneratorContext context) { var surfaceToEyeDistance = LODDistance.GenerateShaderSource(context, new MaterialComputeColorKeys(MaterialKeys.GlossinessMap, MaterialKeys.GlossinessValue, Color.White)); // Diffuse Feature (interpolated by the 'regular' diffuse map) var metalFlakesComputeColorSource = MetalFlakesDiffuseMap.GenerateShaderSource(context, new MaterialComputeColorKeys(MaterialKeys.DiffuseMap, MaterialKeys.DiffuseValue, Color.White)); var mixinDiffuse = new ShaderMixinSource(); // Diffuse uses a custom shader (to perform the interpolation) mixinDiffuse.Mixins.Add(new ShaderClassSource("MaterialSurfaceDiffuseMetalFlakes")); mixinDiffuse.AddComposition("diffuseMap", metalFlakesComputeColorSource); mixinDiffuse.AddComposition("surfaceToEyeDistanceFactor", surfaceToEyeDistance); context.UseStream(MaterialShaderStage.Pixel, MaterialDiffuseMapFeature.DiffuseStream.Stream); context.UseStream(MaterialShaderStage.Pixel, MaterialDiffuseMapFeature.ColorBaseStream.Stream); context.AddShaderSource(MaterialShaderStage.Pixel, mixinDiffuse); }