如何在wpf 3d中使用抗锯齿
伙计们! 我想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设 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.