jiluo
jiluo

Reputation: 2346

How to using anti-aliasing in wpf 3d

guys! I want to implement this in wpf, here's the link: http://www.matthiasdittrich.com/

So I should put some 2d content in viewport3d. I used Viewport2DVisual3D as the container for 2d elements. But I encountered serious aliasing, I added the RenderOptions.EdgeMode="Aliased",but it does not work.

Here's my xaml:

<Viewport3D RenderOptions.EdgeMode="Aliased">
        <Viewport3D.Camera>
            <PerspectiveCamera Position="0, -2, 6" LookDirection="0, 2, -6"/>
        </Viewport3D.Camera>
        <Viewport2DVisual3D RenderOptions.EdgeMode="Aliased">
            <Grid Width="400" Height="400">
            <s:SurfaceScrollViewer>
                <ItemsControl>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                    <Label Background="LightGray"
                                Content="hahaha"/>
                    <Label Background="DarkGray"
                                Content="hahaha"/>
                </ItemsControl>
            </s:SurfaceScrollViewer>
            </Grid>
            <Viewport2DVisual3D.Material>
                <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
            </Viewport2DVisual3D.Material>
            <Viewport2DVisual3D.Geometry>
                <MeshGeometry3D Positions="-1,2,0 -1,-2,0 1,-2,0 1,2,0"
                        TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
            </Viewport2DVisual3D.Geometry>
        </Viewport2DVisual3D>
        <ModelVisual3D>
            <ModelVisual3D.Content>
                <DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
            </ModelVisual3D.Content>
        </ModelVisual3D>
    </Viewport3D>

Can anybody help me? Thanks in advance!

Upvotes: 2

Views: 2254

Answers (1)

Jack Ukleja
Jack Ukleja

Reputation: 13501

I am assuming RenderOptions.EdgeMode="Aliased" is the opposite of ANTI-Aliased so maybe you shouldn't touch that setting.

Upvotes: 2

Related Questions