Skip to content

Instantly share code, notes, and snippets.

@w0wca7a
Last active March 27, 2025 00:37
Show Gist options
  • Save w0wca7a/8735d3eeba1ac0d1f32d87217f8ba988 to your computer and use it in GitHub Desktop.
Save w0wca7a/8735d3eeba1ac0d1f32d87217f8ba988 to your computer and use it in GitHub Desktop.
// Copyright (c) Stride contributors (https://stride3d.net).
// Distributed under the MIT license.
using Stride.Rendering.Materials.ComputeColors;
using Stride.Rendering.Materials;
using Stride.Core.Mathematics;
using Stride.Rendering;
using Stride.Graphics;
namespace MaterialExt
{
public class LayeredMaterial
{
private static Texture _texture;
private static Color _baseColor;
private static Color _additColor;
public MaterialExt(ref Texture texture)
{
_texture = texture;
_baseColor = Color.Azure;
_additColor = Color.Yellow;
}
public MaterialExt(ref Texture texture, Color baseColor, Color additionalColor)
{
_texture = texture;
_baseColor = baseColor;
_additColor = additionalColor;
}
public MaterialDescriptor materialDescriptor = new()
{
Attributes = new MaterialAttributes()
{
Diffuse = new MaterialDiffuseMapFeature(new ComputeColor(
new Color4(
_baseColor))),
DiffuseModel = new MaterialDiffuseLambertModelFeature()
},
Layers =
[
new MaterialBlendLayer()
{
BlendMap = new ComputeTextureScalar(_texture, TextureCoordinate.Texcoord0,
new Vector2(1.0f, 1.0f), new Vector2(0.0f, 0.0f)),
Material = new Material()
{
Descriptor = new MaterialDescriptor()
{
Attributes = new MaterialAttributes()
{
Diffuse = new MaterialDiffuseMapFeature(
new ComputeColor(
_additColor)),
DiffuseModel = new MaterialDiffuseLambertModelFeature(),
}
}
}
}
]
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment