是否有可能以某种方式改变图像刷的色调。我目前正在使用图像刷在 wpf 3d 中创建纹理材质。为了获得选择和分组效果,我需要每个模型最多三种材料。这导致了相当大的性能损失。这是当前代码:
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;
注意。ItemTextures[nr] 是冻结的 BitmapImage
希望有一个解决方案,使代码看起来像这样:
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;
这样,只需要一种材料即可创建所需的效果。