How to make unwashed image in WPF 3d

I have used Viewport3Dand ModelVisual3Dto create a simple ImageBrush with the image (I tried it with JPG, PNG), but it shows that the image is blurry, but the original image is very crisp and clear.

I do not know how to do this with original quality in 3D ...

I also tried some 2D solutions, such as RenderOptions.BitmapScalingModeand SnapsToDevicePixels, but didn't seem to fix the problem in the 3D case.

Has anyone encountered this problem or knew a solution?

The following is an example 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>

+3
source share
2 answers

, 2 (, 512x512 ). , WPF "" 2, , . 2 , ( -, , , ).

, , . , ( ) .

+2

UseLayoutRounding="True" Image.

+1

Source: https://habr.com/ru/post/1742078/


All Articles