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

发布于 2024-10-20 13:30:03 字数 2865 浏览 2 评论 0原文

伙计们! 我想在 wpf 中实现此功能,链接如下: http://www.matthiasdittrich.com/

所以我应该将一些 2d 内容放入 viewport3d 中。我使用 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>

有人可以帮助我吗?提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木有鱼丸 2024-10-27 13:30:03

我假设 RenderOptions.EdgeMode="Aliased" 与 ANTI-Aliased 相反,所以也许您不应该触摸该设置。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文