|
@@ -26,32 +26,6 @@ function NodeMaterial( vertex, fragment ) {
|
|
|
|
|
|
this.updaters = [];
|
|
|
|
|
|
- // onBeforeCompile can't be in the prototype because onBeforeCompile.toString varies per material
|
|
|
-
|
|
|
- this.onBeforeCompile = function ( shader, renderer ) {
|
|
|
-
|
|
|
- var materialProperties = renderer.properties.get( this );
|
|
|
-
|
|
|
- if ( this.version !== materialProperties.__version ) {
|
|
|
-
|
|
|
- this.build( { renderer: renderer } );
|
|
|
-
|
|
|
- shader.uniforms = this.uniforms;
|
|
|
- shader.vertexShader = this.vertexShader;
|
|
|
- shader.fragmentShader = this.fragmentShader;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- // it fix the programCache and share the code with others materials
|
|
|
-
|
|
|
- this.onBeforeCompile.toString = function () {
|
|
|
-
|
|
|
- return scope.needsCompile;
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
}
|
|
|
|
|
|
NodeMaterial.prototype = Object.create( ShaderMaterial.prototype );
|
|
@@ -91,6 +65,43 @@ Object.defineProperties( NodeMaterial.prototype, {
|
|
|
|
|
|
} );
|
|
|
|
|
|
+NodeMaterial.prototype.onBeforeCompile = function ( shader, renderer ) {
|
|
|
+
|
|
|
+ var materialProperties = renderer.properties.get( this );
|
|
|
+
|
|
|
+ if ( this.version !== materialProperties.__version ) {
|
|
|
+
|
|
|
+ this.build( { renderer: renderer } );
|
|
|
+
|
|
|
+ shader.uniforms = this.uniforms;
|
|
|
+ shader.vertexShader = this.vertexShader;
|
|
|
+ shader.fragmentShader = this.fragmentShader;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+NodeMaterial.prototype.customProgramCacheKey = function () {
|
|
|
+
|
|
|
+ var hash = this.getHash();
|
|
|
+
|
|
|
+ return hash;
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+NodeMaterial.prototype.getHash = function () {
|
|
|
+
|
|
|
+ var hash = '{';
|
|
|
+
|
|
|
+ hash += '"vertex":' + this.vertex.getHash() + ',\n';
|
|
|
+ hash += '"fragment":' + this.fragment.getHash() + '\n';
|
|
|
+
|
|
|
+ hash += '}'
|
|
|
+
|
|
|
+ return hash;
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
NodeMaterial.prototype.updateFrame = function ( frame ) {
|
|
|
|
|
|
for ( var i = 0; i < this.updaters.length; ++ i ) {
|