Browse Source

#fix 5008

David Catuhe 7 years ago
parent
commit
6dcd6110dd

+ 4 - 1
src/Materials/Textures/Procedurals/babylon.noiseProceduralTexture.ts

@@ -40,11 +40,14 @@ module BABYLON {
             this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
 
             this.setFloat("brightness", this.brightness);
-            this.setInt("octaves", this.octaves);
             this.setFloat("persistence", this.persistence);
             this.setFloat("timeScale", this._time);
         }
 
+        protected _getDefines(): string {
+            return "#define OCTAVES " + this.octaves;
+        }
+
         /** Generate the current state of the procedural texture */
         public render(useCameraPostProcess?: boolean) {
             this._updateShaderUniforms();

+ 7 - 1
src/Materials/Textures/Procedurals/babylon.proceduralTexture.ts

@@ -116,6 +116,10 @@
             engine._releaseEffect(this._effect);
         }
 
+        protected _getDefines(): string {
+            return "";
+        }
+
 
         public isReady(): boolean {
             var engine = this._engine;
@@ -136,11 +140,13 @@
                 shaders = { vertex: "procedural", fragment: this._fragment };
             }
 
+            let defines = this._getDefines();
+
             this._effect = engine.createEffect(shaders,
                 [VertexBuffer.PositionKind],
                 this._uniforms,
                 this._samplers,
-                "", undefined, undefined, () => {
+                defines, undefined, undefined, () => {
                     this.releaseInternalTexture();
 
                     if (this._fallbackTexture) {

+ 1 - 2
src/Shaders/noise.fragment.fx

@@ -2,7 +2,6 @@
 
 // Uniforms
 uniform float brightness;
-uniform int octaves;
 uniform float persistence;
 uniform float timeScale;
 
@@ -42,7 +41,7 @@ float perlinNoise2D(float x,float y)
     float sum = 0.0;
     float frequency = 0.0;
     float amplitude = 0.0;
-    for(int i = 0; i < octaves; i++)
+    for(int i = 0; i < OCTAVES; i++)
     {
         frequency = pow(2.0, float(i));
         amplitude = pow(persistence, float(i));