如何为3D对象(如Cylinder)在DirectX中实现Geometry Shader? [英] How to implement Geometry Shader in DirectX for a 3D object like Cylinder?

查看:168
本文介绍了如何为3D对象(如Cylinder)在DirectX中实现Geometry Shader?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关如何在Cylinder上实现几何着色器以及[maxvertexcount()],
的值是什么的帮助,我们是否需要在ModelClass中提供顶点和索引的值?

I need help on how to implement Geometry Shader on Cylinder and what is the value of [maxvertexcount()], and do we need to provide the values of vertices and indices in ModelClass?

推荐答案

Direct3D的Geometry Shader阶段并非旨在生成像圆柱体这样的完整几何,也不是真正为Tessellation设计的。

The Geometry Shader stage of Direct3D is not intended for generating complete geometry like a cylinder, nor it is really designed for Tessellation.

https://docs.microsoft.com/zh-cn/windows/uwp/graphics-concepts/geometry-shader-stage--gs-

您可以做一些少量的放大,但是通常,当您跳过GS阶段或输出与输入相同数量的顶点时,硬件实现效果最佳。与其他方法相比,即使是GS最初的用例,例如从单个输入点生成点精灵(四边形),也效率不高。

You can do some small amount of amplification, but generally the hardware implementations work best when you either skip the GS stage or you output the same number of vertices as your inputs. Even initial 'use cases' for GS like generating a point-sprite (a quad) from a single input point have proven to be fairly inefficient compared to other methods.

GS正在处理邻接信息,或者在不复制顶点的情况下进行基于面部的计算,例如实现经典的平面阴影。几何着色器在进行非真实感渲染时非常有用。 GS阶段还可以通过Stream Out和控制管道中的多渲染目标选择来做一些有趣的技巧。

The primary value of the GS is working with adjacency information, or doing face-based computations like implementing classic 'flat-shading' without duplicating vertices. Geometry Shader can be very useful in doing Non-Photorealistic Rendering. The GS stage can also do some interesting tricks with Stream Out and controlling multi-render target selection in the pipeline.

https://npr-art.blogspot.com/2009/07/geometry-shader-silhouettes.html

如果要生成圆柱体,最好的选择是在CPU上构建它。请参阅 DirectX工具包<中的 GeometricPrimitive / a>。

If you want to generate a Cylinder, your best option is to build it on the CPU. See GeometricPrimitive in DirectX Tool Kit.

这篇关于如何为3D对象(如Cylinder)在DirectX中实现Geometry Shader?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆