javascript WebGL 几何着色器等效?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8641119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 04:04:36  来源:igfitidea点击:

WebGL Geometry Shader Equivalent?

javascriptopengl-esgeometrywebgl

提问by Emmanuel M. Smith

I'm currently researching a way to produce non-photorealistic rendering in webgl. The best looking algorithm I've found so far for edge detection was implemented with OpenGL's geometry shader, here. Specifically GL_TRIANGLES_ADJACENCY.

我目前正在研究一种在 webgl 中生成非真实感渲染的方法。到目前为止,我发现的最好看的边缘检测算法是用 OpenGL 的几何着色器实现的,这里。特别是 GL_TRIANGLES_ADJACENCY。

I was wondering if there was an equivalent in WebGL or even how would I go about porting this code over to Javascript.

我想知道在 WebGL 中是否有等价物,甚至我将如何将此代码移植到 Javascript。

回答by Mortennobel

Geometry shaders is not available in WebGL.

几何着色器在 WebGL 中不可用。

However there is plenty of ways to do edge detection. E.g. you can use image space based algorithms, such as

然而,有很多方法可以进行边缘检测。例如,您可以使用基于图像空间的算法,例如

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.93.9731&rep=rep1&type=pdf

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.93.9731&rep=rep1&type=pdf

Or take a look in "Real-time Rendering - 3rd edition" (book). In this book there is a lot of examples of NPR, of which most will run fine on WebGL.

或者查看“实时渲染 - 第 3 版”(书籍)。本书中有很多 NPR 示例,其中大部分都可以在 WebGL 上正常运行。

http://www.realtimerendering.com/

http://www.realtimerendering.com/

回答by cdiggins

WebGL currently only supports pixel shaders and vertex shaders not geometry shaders.

WebGL 目前仅支持像素着色器和顶点着色器,不支持几何着色器。

That said there is an interesting article and demo showing how to emulate geometry shaders in WebGL at: https://acko.net/blog/yak-shading/.

也就是说,有一篇有趣的文章和演示展示了如何在 WebGL 中模拟几何着色器:https: //acko.net/blog/yak-shading/