【问题标题】:Ashima Perlin noise shader not working with recent versions of Three.JSAshima Perlin 噪声着色器不适用于最新版本的 Three.JS
【发布时间】:2013-05-21 20:02:00
【问题描述】:

为了能够使用最新的 Three.JS,我希望 SO 上有人遇到过这个问题,因为 Google 什么也没给我。

我正在使用 Ashima Perlin 噪声着色器(参见示例)-http://www.clicktorelease.com/blog/experiments-with-perlin-noise

如果我使用 Three.JS 的 48 版(最新版本是 59),我可以完美地完成这项工作。

尝试使用此版本的最新版本时会出现此错误:

ERROR: 0:301: 'objectMatrix' : undeclared identifier 
ERROR: 0:301: 'objectMatrix' :  left of '[' is not of type array, matrix, or vector  
ERROR: 0:301: 'xyz' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:301: 'objectMatrix' :  left of '[' is not of type array, matrix, or vector  
ERROR: 0:301: 'xyz' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:301: 'objectMatrix' :  left of '[' is not of type array, matrix, or vector  
ERROR: 0:301: 'xyz' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:301: 'constructor' : not enough data provided for construction 
 three.min.js:40

这通常是我会为其他人调试、修复和推送到 git 的东西,但我没有 C 知识或着色器知识来调试它。

【问题讨论】:

标签: javascript 3d three.js webgl shader


【解决方案1】:

好的,任何人都想知道为什么这个演示不能使用最新版本的 three.js:http://www.clicktorelease.com/code/perlin/chrome.html

这是因为 varname 发生了变化,您只需更改 void main() 中的顶点着色器。

改变这一行:

vec3 nWorld = normalize( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * modifiedNormal );

到这里:

vec3 nWorld = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * modifiedNormal );

感谢 @gaitat 提供的指向 Three.js 迁移页面的帮助,非常有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-26
    • 2020-04-17
    • 2014-02-15
    • 2020-06-06
    • 1970-01-01
    • 2011-09-20
    相关资源
    最近更新 更多