本文介绍了如何在 wpf 3d 中使用抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们!我想在 wpf 中实现这一点,这是链接:http://www.matthiasdittrich.com/>

所以我应该在 viewport3d 中放入一些 2d 内容.我使用 Viewport2DVisual3D 作为 2d 元素的容器.但是我遇到了严重的锯齿,我加了RenderOptions.EdgeMode="Aliased",但是没有用.

这是我的 xaml:

<Viewport3D.Camera><PerspectiveCamera Position="0, -2, 6" LookDirection="0, 2, -6"/></Viewport3D.Camera><Viewport2DVisual3D RenderOptions.EdgeMode="别名"><网格宽度=400"高度=400"><项目控制><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/><标签背景=浅灰色"内容="哈哈哈"/><标签背景="深灰色"内容="哈哈哈"/></ItemsControl></s:SurfaceScrollViewer></网格><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>

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

解决方案

我假设 RenderOptions.EdgeMode="Aliased" 与 ANTI-Aliased 相反,所以也许你不应该碰那个设置.

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!

解决方案

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

这篇关于如何在 wpf 3d 中使用抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:23