首页 > 解决方案 > 在 glsl 中启用扩展和 fwidth

问题描述

我正在使用 webGL,我想像fwidth在 Three.js 中那样使用它。在 .glsl 文件中,我添加了这样的扩展名:

#ifndef GL_ES
// Non OpenGL ES devices doesnt support precision qualifiers, so we do
// nothing instead
#define lowp
#define mediump
#define highp
#else
// to have functions like fwidth for OpenGL ES or WebGL, the extension should
// be explicitly enabled.
#extension GL_OES_standard_derivatives : enable
#endif

但我不断收到此错误:

Error compiling FRAGMENT_SHADER: WARNING: 0:14: '
' : extension directive should occur before any non-preprocessor tokens
WARNING: 0:14: 'GL_OES_standard_derivatives' : extension is not supported
ERROR: 0:47: 'fwidth' : no matching overloaded function found

如果有人知道如何解决这个问题 - 很高兴得到提示。

标签: glslwebgl

解决方案


推荐阅读