本文介绍了在Three.js着色器上启用扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Three.js着色器上启用扩展?

How can I enable an extension on a Three.js shader?

到目前为止,我的代码:

My code so far:

获取扩展名:

var domElement = document.createElement( 'canvas' );
var gl = domElement.getContext('webgl') || domElement.getContext('experimental-webgl');
gl.getExtension('OES_standard_derivatives');

在我的着色器上:

fragmentShader: [
    "#extension GL_OES_standard_derivatives : enable",
    "code..."
]...

控制台输出:
警告:0:26:不支持扩展名'GL_OES_standard_derivatives'
错误:0:32:"dFdx":找不到匹配的重载函数
错误:0:32:'=':无法从'const mediump float'转换为'float的2分量向量'
错误:0:33:"dFdy":找不到匹配的重载函数
错误:0:33:'=':无法从'const mediump float'转换为'float的2-component vector'

The console output:
WARNING: 0:26: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:32: 'dFdx' : no matching overloaded function found
ERROR: 0:32: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:33: 'dFdy' : no matching overloaded function found
ERROR: 0:33: '=' : cannot convert from 'const mediump float' to '2-component vector of float'

在阅读 github上的问题之后,我尝试了以下示例:从 http://jsfiddle.net/VJca4/我收到这些错误

After reading this issue on github, I tried this example: From http://jsfiddle.net/VJca4/ I get these errors

警告:0:27:不支持扩展名'GL_OES_standard_derivatives'
错误:0:30:'=':无法从'const mediump float'转换为'float的2-component vector'
错误:0:31:"dFdx":找不到匹配的重载函数
错误:0:31:'=':无法从'const mediump float'转换为'float的2-component vector'

WARNING: 0:27: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:30: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:31: 'dFdx' : no matching overloaded function found
ERROR: 0:31: '=' : cannot convert from 'const mediump float' to '2-component vector of float'

推荐答案

您还应该能够做到这一点:

You should also be able to do this:

renderer.context.getExtension('OES_standard_derivatives');

这篇关于在Three.js着色器上启用扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:18