Browse Source

Fix gradient material

David Catuhe 7 years ago
parent
commit
4524778945

File diff suppressed because it is too large
+ 3169 - 3169
dist/preview release/babylon.d.ts


+ 1 - 0
dist/preview release/materialsLibrary/babylon.gradientMaterial.d.ts

@@ -8,6 +8,7 @@ declare module BABYLON {
         bottomColor: Color3;
         bottomColor: Color3;
         bottomColorAlpha: number;
         bottomColorAlpha: number;
         offset: number;
         offset: number;
+        scale: number;
         smoothness: number;
         smoothness: number;
         disableLighting: boolean;
         disableLighting: boolean;
         private _scaledDiffuse;
         private _scaledDiffuse;

File diff suppressed because it is too large
+ 7 - 2
dist/preview release/materialsLibrary/babylon.gradientMaterial.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js


+ 1 - 0
dist/preview release/materialsLibrary/babylonjs.materials.d.ts

@@ -27,6 +27,7 @@ declare module BABYLON {
         bottomColor: Color3;
         bottomColor: Color3;
         bottomColorAlpha: number;
         bottomColorAlpha: number;
         offset: number;
         offset: number;
+        scale: number;
         smoothness: number;
         smoothness: number;
         disableLighting: boolean;
         disableLighting: boolean;
         private _scaledDiffuse;
         private _scaledDiffuse;

File diff suppressed because it is too large
+ 7 - 2
dist/preview release/materialsLibrary/babylonjs.materials.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/materialsLibrary/babylonjs.materials.min.js


+ 1 - 0
dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts

@@ -32,6 +32,7 @@ declare module BABYLON {
         bottomColor: Color3;
         bottomColor: Color3;
         bottomColorAlpha: number;
         bottomColorAlpha: number;
         offset: number;
         offset: number;
+        scale: number;
         smoothness: number;
         smoothness: number;
         disableLighting: boolean;
         disableLighting: boolean;
         private _scaledDiffuse;
         private _scaledDiffuse;

+ 5 - 1
materialsLibrary/src/gradient/babylon.gradientMaterial.ts

@@ -90,6 +90,9 @@ module BABYLON {
         public offset = 0;
         public offset = 0;
 
 
         @serialize()
         @serialize()
+        public scale = 1.0;        
+
+        @serialize()
         public smoothness = 1.0;
         public smoothness = 1.0;
 
 
         @serialize()
         @serialize()
@@ -195,7 +198,7 @@ module BABYLON {
                     "vDiffuseInfos",
                     "vDiffuseInfos",
                     "mBones",
                     "mBones",
                     "vClipPlane", "diffuseMatrix",
                     "vClipPlane", "diffuseMatrix",
-                    "topColor", "bottomColor", "offset", "smoothness"
+                    "topColor", "bottomColor", "offset", "smoothness", "scale"
                 ];
                 ];
                 var samplers = ["diffuseSampler"];
                 var samplers = ["diffuseSampler"];
                 var uniformBuffers = new Array<string>();
                 var uniformBuffers = new Array<string>();
@@ -282,6 +285,7 @@ module BABYLON {
             this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
             this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
             this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
             this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
             this._activeEffect.setFloat("offset", this.offset);
             this._activeEffect.setFloat("offset", this.offset);
+            this._activeEffect.setFloat("scale", this.scale);
             this._activeEffect.setFloat("smoothness", this.smoothness);
             this._activeEffect.setFloat("smoothness", this.smoothness);
 
 
             this._afterBind(mesh, this._activeEffect);
             this._afterBind(mesh, this._activeEffect);

+ 2 - 1
materialsLibrary/src/gradient/gradient.fragment.fx

@@ -8,6 +8,7 @@ uniform vec4 vDiffuseColor;
 uniform vec4 topColor;
 uniform vec4 topColor;
 uniform vec4 bottomColor;
 uniform vec4 bottomColor;
 uniform float offset;
 uniform float offset;
+uniform float scale;
 uniform float smoothness;
 uniform float smoothness;
 
 
 // Input
 // Input
@@ -52,7 +53,7 @@ void main(void) {
 
 
 	vec3 viewDirectionW = normalize(vEyePosition - vPositionW);
 	vec3 viewDirectionW = normalize(vEyePosition - vPositionW);
 
 
-    float h = normalize(vPosition).y + offset;
+    float h = vPosition.y * scale + offset;
     float mysmoothness = clamp(smoothness, 0.01, max(smoothness, 10.));
     float mysmoothness = clamp(smoothness, 0.01, max(smoothness, 10.));
 
 
     vec4 baseColor = mix(bottomColor, topColor, max(pow(max(h, 0.0), mysmoothness), 0.0));
     vec4 baseColor = mix(bottomColor, topColor, max(pow(max(h, 0.0), mysmoothness), 0.0));