/// <summary> /// Initializes a new instance of the <see cref="MaterialDisplacementMapFeature"/> class. /// </summary> /// <param name="displacementMap">The displacement map.</param> public MaterialDisplacementMapFeature(IComputeScalar displacementMap) { ScaleAndBias = true; DisplacementMap = displacementMap; Intensity = new ComputeFloat(1.0f); Stage = DisplacementMapStage.Vertex; }
/// <summary> /// Clamps <see cref="ComputeColors.ComputeFloat"/> value within a specified range [min; max]. /// </summary> /// <param name="key">Input scalar.</param> /// <param name="min">The minimum value.</param> /// <param name="max">The maximum value.</param> public static void ClampFloat([NotNull] this IComputeScalar key, float min, float max) { var asFloat = key as ComputeColors.ComputeFloat; if (asFloat != null) { asFloat.Value = MathUtil.Clamp(asFloat.Value, min, max); } }
/// <summary> /// Pushes a new layer with the specified blend map. /// </summary> /// <param name="blendMap">The blend map used by this layer.</param> public void PushLayer(IComputeScalar blendMap) { // We require a blend layer expect for the top level one. if (currentLayerContext != null && blendMap == null) { throw new ArgumentNullException(nameof(blendMap), "Blendmap parameter cannot be null for a child layer"); } var newLayer = new MaterialBlendLayerContext(this, currentLayerContext, blendMap); if (currentLayerContext != null) { currentLayerContext.Children.Add(newLayer); } currentLayerContext = newLayer; }
/// <summary> /// Initializes a new instance of <see cref="MaterialBlendLayerContext"/>. /// </summary> /// <param name="context">The material generator context</param> /// <param name="parentLayerContext">The parent layer context</param> /// <param name="blendMap">The blend map used for this layer</param> public MaterialBlendLayerContext(MaterialGeneratorContext context, MaterialBlendLayerContext parentLayerContext, IComputeScalar blendMap) { if (context == null) throw new ArgumentNullException(nameof(context)); Context = context; Parent = parentLayerContext; BlendMap = blendMap; Children = new List<MaterialBlendLayerContext>(); ShadingModels = new MaterialShadingModelCollection(); ContextPerStage = new Dictionary<MaterialShaderStage, MaterialBlendLayerPerStageContext>(); foreach (MaterialShaderStage stage in Enum.GetValues(typeof(MaterialShaderStage))) { ContextPerStage[stage] = new MaterialBlendLayerPerStageContext(); } PendingPixelLayerContext = new MaterialBlendLayerPerStageContext(); }
/// <summary> /// Initializes a new instance of <see cref="MaterialBlendLayerContext"/>. /// </summary> /// <param name="context">The material generator context</param> /// <param name="parentLayerContext">The parent layer context</param> /// <param name="blendMap">The blend map used for this layer</param> public MaterialBlendLayerContext(MaterialGeneratorContext context, MaterialBlendLayerContext parentLayerContext, IComputeScalar blendMap) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Context = context; Parent = parentLayerContext; BlendMap = blendMap; Children = new List <MaterialBlendLayerContext>(); ShadingModels = new MaterialShadingModelCollection(); ContextPerStage = new Dictionary <MaterialShaderStage, MaterialBlendLayerPerStageContext>(); foreach (MaterialShaderStage stage in Enum.GetValues(typeof(MaterialShaderStage))) { ContextPerStage[stage] = new MaterialBlendLayerPerStageContext(); } PendingPixelLayerContext = new MaterialBlendLayerPerStageContext(); }
/// <summary> /// Initializes a new instance of the <see cref="MaterialGlossinessMapFeature"/> class. /// </summary> /// <param name="glossinessMap">The glossiness map.</param> public MaterialGlossinessMapFeature(IComputeScalar glossinessMap) { GlossinessMap = glossinessMap; }
/// <summary> /// Initializes a new instance of the <see cref="MaterialMetalnessMapFeature"/> class. /// </summary> /// <param name="metalnessMap">The metalness map.</param> public MaterialMetalnessMapFeature(IComputeScalar metalnessMap) { MetalnessMap = metalnessMap; }
public void SetStreamBlend(MaterialShaderStage stage, IComputeScalar blendMap) { SetStream(stage, MaterialBlendLayer.BlendStream, blendMap, MaterialKeys.BlendMap, MaterialKeys.BlendValue, null); }
public MaterialRoughnessMapFeature(IComputeScalar roughnessMap) { RoughnessMap = roughnessMap; }