Is it somehow possible to change the hue of an imagebrush. I'm currently using an imagebrush to create a texture material in wpf 3d. To get selection and grouping effects, i need up to three materials per model. This results in quite the performance hit. Here is the current code:
DiffuseMaterial itemImageMaterial = new DiffuseMaterial(new ImageBrush(ItemTextures[nr]) { Stretch = Stretch.Fill });
var meshGeom = new MeshGeometry3D();
meshGeom.Positions = cubesPositions;
meshGeom.TriangleIndices = cubesIndeces;
GeometryModel3D geoMod = new GeometryModel3D();
geoMod.Geometry = meshGeom;
MaterialGroup mg = new MaterialGroup();
mg.Children.Add(itemImageMaterial);
if (applyGroupOverlay) mg.Children.Add(groupMaterials[groupNr]);
if (applyHighlight) mg.Children.Add(highlightMaterials[highlightNr]);
mg.Freeze();
geoMod.Material = mg;
(geoMod.Geometry as MeshGeometry3D).TextureCoordinates = cubesTextureCoords;
Visual3DModel = geoMod;
nb. ItemTextures[nr] is a freezed BitmapImage
Hopefully there is a solution so that the code can look something like this:
ImageBrush brush = new ImageBrush(ItemTextures[nr]) { Stretch = Stretch.Fill }
if (applyGroupOverlay){
//tint brush here
}
if (applyHighlight) {
//tint brush some more here
}
DiffuseMaterial itemImageMaterial = new DiffuseMaterial(brush);
var meshGeom = new MeshGeometry3D();
meshGeom.Positions = cubesPositions;
meshGeom.TriangleIndices = cubesIndeces;
GeometryModel3D geoMod = new GeometryModel3D();
geoMod.Geometry = meshGeom;
geoMod.Material = itemImageMaterial;
(geoMod.Geometry as MeshGeometry3D).TextureCoordinates = cubesTextureCoords;
This way, only a single material is needed to create the desired effects.