我是'wpf'的新手,我遇到了以下问题:在我的项目中,我尝试使用小分辨率.png作为模型的纹理。当我在 Blender(我在其中构建立方体)中禁用 mipmapping 时,结果正是我想要的:
但在 wpf 项目中,模糊效果永远不会关闭:
这是我的代码:
<Window x:Class="GCS.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="504" Width="525" ShowInTaskbar="True">
<Grid>
<Viewport3D Name="myViewport"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Viewport3D.Resources>
<MaterialGroup x:Key="Material">
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<ImageBrush RenderOptions.BitmapScalingMode="NearestNeighbor" ViewportUnits="Absolute" ImageSource="char.png"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</Viewport3D.Resources>
<Viewport3D.Camera>
<PerspectiveCamera Position="7.8,-11,-0.8" NearPlaneDistance="1" FarPlaneDistance="50" LookDirection="-0.4,0.9,-0.3" UpDirection="0,0,1" FieldOfView="15"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<GeometryModel3D Material="{StaticResource Material}">
<GeometryModel3D.Transform>
<Transform3DGroup>
<TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="-7"/>
<ScaleTransform3D ScaleZ="1" ScaleY="1" ScaleX="1"/>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="1,0,0" Angle="92"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="7"/>
<TranslateTransform3D OffsetZ="-6.622" OffsetX="0" OffsetY="-0.023"/>
</Transform3DGroup>
</GeometryModel3D.Transform>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Normals="-1,0,0 -1,0,0 -1,0,0 -1,0,0 0,0,-1 0,0,-1 0,0,-1 0,0,-1 1,0,0 1,0,0 1,0,0 1,0,0 0,0,1 0,0,1 0,0,1 0,0,1 0,-1,0 0,-1,0 0,-1,0 0,-1,0 0,1,0 0,1,0 0,1,0 0,1,0"
Positions="-1,6,-1 -1,6,1 -1,8,1 -1,8,-1 -1,8,-1 1,8,-1 1,6,-1 -1,6,-1 1,8,-1 1,8,1 1,6,1 1,6,-1 -1,6,1 1,6,1 1,8,1 -1,8,1 -1,6,1 -1,6,-1 1,6,-1 1,6,1 1,8,1 1,8,-1 -1,8,-1 -1,8,1"
TextureCoordinates="0,0.5 0.125,0.5 0.125,0.25 0,0.25 0.5,0.25 0.375,0.25 0.375,0.5 0.5,0.5 0.375,0.25 0.25,0.25 0.25,0.5 0.375,0.5 0.125,0.5 0.25,0.5 0.25,0.25 0.125,0.25 0.375,0.25 0.375,0 0.25,0 0.25,0.25 0.25,0.25 0.25,0 0.125,0 0.125,0.25"
TriangleIndices="0 1 2 0 2 3 4 5 6 4 6 7 8 9 10 8 10 11 12 13 14 12 14 15 16 17 18 16 18 19 20 21 22 20 22 23"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<AmbientLight Color="#ffffff"/>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
</Grid>
我在网上做了很多搜索,尝试了很多方法:强制软件渲染,使用DrawingBrush而不是ImageBrush,但结果是一样的。有没有办法克服这种渲染?