是否可以使用 WebGL 运行 #version 120 着色器 [英] Is it possible to run #version 120 shaders with WebGL

查看:31
本文介绍了是否可以使用 WebGL 运行 #version 120 着色器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多 GLSL 片段着色器,我几乎可以保证它们符合 #version 120 它们使用标准的、不符合 ES 的值,并且它们没有任何 ES 特定的值编译指示.

我真的很想使用 WebGL 为他们制作一个网页预览器.预览器不会在移动设备上使用.这可行吗?与 GLSL 版本相比,WebGL 中向 GLSL 着色器公开的功能集是否受到限制?是否存在精度差异?

我已经尝试过使用 THREE.js 但这并没有真正影响它,因为它在将我的着色器代码加载到 GPU 之前弄乱了它(我做不到).

简而言之:GLSL 规范是否足以让我运行这些着色器?...因为如果它不是我所追求的则不可行,我应该放弃它.

解决方案

不,WebGL 着色器必须是版本 #100.其他任何事情都是不允许的.

如果您很好奇这是为什么,因为 WebGL 需要尽可能地在任何地方运行.如果您可以选择任何版本,您的网页将仅在具有处理该版本的 GPU/驱动程序的系统上运行.

WebGL 的下一版本将提高版本号.它将允许 GLSL ES 3.0(注意 ES).截至 2016 年 5 月,它目前在 Chrome 和 Firefox 的标志后面可用

I have a number of GLSL fragment shaders for which I can pretty much guarantee that they conform to #version 120 They use standard, non-ES conformant values and they do not have any ES-specific pragmas.

I really want to make a web previewer for them using WebGL. The previewer won't be used on mobile. Is this feasible? Is the feature set exposed to GLSL shaders in WebGL restricted compared to that GLSL version? Are there precision differences?

I've already tried playing with THREE.js but that doesn't really rub it since it mucks up my shader code before loading it onto the GPU (which I cannot do).

In short: is the GLSL spec sufficient for me to run those shaders?.. because if it isn't what I am after is not doable and I should just drop it.

解决方案

No, WebGL shaders must be version #100. Anything else is disallowed.

If you're curious why it's because, as much as possible, WebGL needs to run everywhere. If you could choose any version your web page would only run on systems with GPUs/Drivers that handled that version.

The next version of WebGL will raise the version number. It will allow GLSL ES 3.0 (note the ES). It's currently available behind a flag in Chrome and Firefox as of May 2016

这篇关于是否可以使用 WebGL 运行 #version 120 着色器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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