private void AddSecondarySpecularGlintsNoiseTexture(MaterialGeneratorContext context, ShaderMixinSource shaderSource) { MaterialComputeColorKeys materialComputeColorKeys = new MaterialComputeColorKeys(SecondarySpecularReflectionNoiseTexture, SecondarySpecularReflectionNoiseValue); var computeColorSource = HairSecondarySpecularGlintsNoise.GenerateShaderSource(context, materialComputeColorKeys); shaderSource.AddComposition("SecondarySpecularGlintsNoiseTexture", computeColorSource); }
private void AddSpecularHighlightsShiftNoiseTexture(MaterialGeneratorContext context, ShaderMixinSource shaderSource) { MaterialComputeColorKeys materialComputeColorKeys = new MaterialComputeColorKeys(PrimarySpecularReflectionNoiseTexture, PrimarySpecularReflectionNoiseValue); var computeColorSource = HairSpecularHighlightsShiftNoise.GenerateShaderSource(context, materialComputeColorKeys); shaderSource.AddComposition("SpecularHighlightsShiftNoiseTexture", computeColorSource); }
} = 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); }
private void AddClearCoatNormalMap(MaterialGeneratorContext context) { var computeColorKeys = new MaterialComputeColorKeys(MaterialKeys.NormalMap, MaterialKeys.NormalValue, MaterialNormalMapFeature.DefaultNormalColor, false); var computeColorSource = OrangePeelNormalMap.GenerateShaderSource(context, computeColorKeys); // Orange Peel Normal Map var mixinNormalMap = new ShaderMixinSource(); // Inform the context that we are using matNormal (from the MaterialSurfaceNormalMap shader) context.UseStreamWithCustomBlend(MaterialShaderStage.Pixel, "matNormal", new ShaderClassSource("MaterialStreamNormalBlend")); context.Parameters.Set(MaterialKeys.HasNormalMap, true); mixinNormalMap.Mixins.Add(new ShaderClassSource("MaterialSurfaceNormalMap", OrangePeelIsXYNormal, OrangePeelScaleAndBias)); mixinNormalMap.AddComposition("normalMap", computeColorSource); context.AddShaderSource(MaterialShaderStage.Pixel, mixinNormalMap); }
public ObjectParameterKey <Texture> GetTextureKey(ComputeTextureBase computeTexture, MaterialComputeColorKeys baseKeys) { var keyResolved = (ObjectParameterKey <Texture>)(computeTexture.Key ?? baseKeys.TextureBaseKey ?? MaterialKeys.GenericTexture); return(GetTextureKey(computeTexture.Texture, keyResolved, baseKeys.DefaultTextureValue)); }