I used Viewport3D
and ModelVisual3D
to create a simple ImageBrush with an image (I tried it with JPG, PNG), but it shows the image blurry, but the original image is very sharp and clear.
I don't know how to make it with the original quality in 3D...
I also tried some 2D solutions like RenderOptions.BitmapScalingMode
and SnapsToDevicePixels
but they do not seem to not work in the 3D case.
Has anyone encountered this problem or know the solution?
below is sample code:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window6" Height="600" Width="600">
<Window.Resources>
<MeshGeometry3D x:Key="Card1" Positions="-0.67,1,0 -0.67,-1,0 0.67,-1,0 0.67,1,0"
TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3" />
</Window.Resources>
<DockPanel Height="600" Width="600">
<Viewport3D Width="415.67" x:Name="viewport" Margin="0,23.363,0,64.363" DockPanel.Dock="Left">
<Viewport3D.Camera>
<PerspectiveCamera x:Name="perCamera" x:Uid="perCamera" FieldOfView="60" Position="0,0,5" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup >
<GeometryModel3D Geometry="{StaticResource Card1}">
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="images\card.png"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<!-- light -->
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</DockPanel>