2013-05-27 29 views
2

爲了能夠使用最新的Three.JS,我希望有人經歷過這個問題,因爲Google沒有給我任何東西。Ashima Perlin噪聲着色器不能與最新版本的Three.JS一起工作

我使用阿詩瑪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知識或着色器知識來調試這個。

+1

井釋放48與58(目前)是很久以前。您需要按照https://github.com/mrdoob/three.js/wiki/Migration上的遷移指南和/或https://github.com/mrdoob/three.js上的更改指南來更新您的代碼。如果您發佈代碼或jsfiddle,可以提供一些幫助。 – gaitat

回答

4

好了,任何人都試圖找到爲什麼這個演示不會與最新版本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所遷移的頁面,非常有幫助的輔助。