如何在wpf 3d中使用抗锯齿

时间:2011-03-07 12:40:48

标签: wpf 3d antialiasing

家伙! 我想在wpf中实现这个,这里是链接:http://www.matthiasdittrich.com/

所以我应该在viewport3d中添加一些2d内容。我使用Viewport2DVisual3D作为2d元素的容器。但是我遇到了严重的别名,我添加了RenderOptions.EdgeMode =“Aliased”,但它不起作用。

这是我的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>

任何人都可以帮助我吗?提前谢谢!

1 个答案:

答案 0 :(得分:2)

我假设RenderOptions.EdgeMode =“Aliased”与 ANTI -Aliased相反,所以也许你不应该触摸那个设置。