Jelajahi Sumber

GirdMAterial Fog

sebavan 8 tahun lalu
induk
melakukan
6e6fd9af31
26 mengubah file dengan 4197 tambahan dan 11880 penghapusan
  1. 1 1
      materialsLibrary/dist/babylon.fireMaterial.js
  2. 1 1
      materialsLibrary/dist/babylon.fireMaterial.min.js
  3. 1 1
      materialsLibrary/dist/babylon.furMaterial.js
  4. 1 1
      materialsLibrary/dist/babylon.furMaterial.min.js
  5. 1 1
      materialsLibrary/dist/babylon.gradientMaterial.js
  6. 1 1
      materialsLibrary/dist/babylon.gradientMaterial.min.js
  7. 17 4
      materialsLibrary/dist/babylon.gridMaterial.js
  8. 1 1
      materialsLibrary/dist/babylon.gridMaterial.min.js
  9. 6 4
      materialsLibrary/dist/babylon.lavaMaterial.js
  10. 1 1
      materialsLibrary/dist/babylon.lavaMaterial.min.js
  11. 1 1
      materialsLibrary/dist/babylon.normalMaterial.js
  12. 1 1
      materialsLibrary/dist/babylon.normalMaterial.min.js
  13. 1 2
      materialsLibrary/dist/babylon.simpleMaterial.js
  14. 1 1
      materialsLibrary/dist/babylon.simpleMaterial.min.js
  15. 1 1
      materialsLibrary/dist/babylon.terrainMaterial.js
  16. 1 1
      materialsLibrary/dist/babylon.terrainMaterial.min.js
  17. 1 1
      materialsLibrary/dist/babylon.triPlanarMaterial.js
  18. 1 1
      materialsLibrary/dist/babylon.triPlanarMaterial.min.js
  19. 81 4
      materialsLibrary/dist/babylon.waterMaterial.js
  20. 1 1
      materialsLibrary/dist/babylon.waterMaterial.min.js
  21. 1 0
      materialsLibrary/dist/dts/babylon.lavaMaterial.d.ts
  22. 23 1
      materialsLibrary/dist/dts/babylon.waterMaterial.d.ts
  23. 44 26
      materialsLibrary/materials/grid/babylon.gridmaterial.ts
  24. 10 4
      materialsLibrary/materials/grid/grid.fragment.fx
  25. 11 0
      materialsLibrary/materials/grid/grid.vertex.fx
  26. 3987 11819
      materialsLibrary/test/refs/babylon.max.js

File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.furMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.furMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.gradientMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.gradientMaterial.min.js


File diff ditekan karena terlalu besar
+ 17 - 4
materialsLibrary/dist/babylon.gridMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.gridMaterial.min.js


File diff ditekan karena terlalu besar
+ 6 - 4
materialsLibrary/dist/babylon.lavaMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.lavaMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.normalMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.normalMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 2
materialsLibrary/dist/babylon.simpleMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.simpleMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.terrainMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.terrainMaterial.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.triPlanarMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.triPlanarMaterial.min.js


File diff ditekan karena terlalu besar
+ 81 - 4
materialsLibrary/dist/babylon.waterMaterial.js


File diff ditekan karena terlalu besar
+ 1 - 1
materialsLibrary/dist/babylon.waterMaterial.min.js


+ 1 - 0
materialsLibrary/dist/dts/babylon.lavaMaterial.d.ts

@@ -11,6 +11,7 @@ declare module BABYLON {
         private _lastTime;
         diffuseColor: Color3;
         disableLighting: boolean;
+        maxSimultaneousLights: number;
         private _worldViewProjectionMatrix;
         private _scaledDiffuse;
         private _renderId;

+ 23 - 1
materialsLibrary/dist/dts/babylon.waterMaterial.d.ts

@@ -26,7 +26,19 @@ declare module BABYLON {
         */
         bumpHeight: number;
         /**
-        * @param {number}: The water color blended with the reflection and refraction samplers
+         * @param {boolean}: Add a smaller moving bump to less steady waves.
+         */
+        bumpSuperimpose: boolean;
+        /**
+         * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
+         */
+        fresnelSeparate: boolean;
+        /**
+         * @param {boolean}: bump Waves modify the reflection.
+         */
+        bumpAffectsReflection: boolean;
+        /**
+        * @param {number}: The water color blended with the refraction (near)
         */
         waterColor: Color3;
         /**
@@ -34,6 +46,14 @@ declare module BABYLON {
         */
         colorBlendFactor: number;
         /**
+         * @param {number}: The water color blended with the reflection (far)
+         */
+        waterColor2: Color3;
+        /**
+         * @param {number}: The blend factor related to the water color (reflection, far)
+         */
+        colorBlendFactor2: number;
+        /**
         * @param {number}: Represents the maximum length of a wave
         */
         waveLength: number;
@@ -50,10 +70,12 @@ declare module BABYLON {
         private _renderId;
         private _defines;
         private _cachedDefines;
+        private _useLogarithmicDepth;
         /**
         * Constructor
         */
         constructor(name: string, scene: Scene, renderTargetSize?: Vector2);
+        useLogarithmicDepth: boolean;
         refractionTexture: RenderTargetTexture;
         reflectionTexture: RenderTargetTexture;
         addToRenderList(node: any): void;

+ 44 - 26
materialsLibrary/materials/grid/babylon.gridmaterial.ts

@@ -4,60 +4,62 @@ module BABYLON {
     class GRIDMaterialDefines extends MaterialDefines {
         public TRANSPARENT = false;
 
+        public FOG = false;
+
         constructor() {
             super();
             this._keys = Object.keys(this);
         }
     }
-    
+
     /**
      * The grid materials allows you to wrap any shape with a grid.
      * Colors are customizable.
      */
     export class GridMaterial extends BABYLON.Material {
-        
+
         /**
          * Main color of the grid (e.g. between lines)
          */
         @serializeAsColor3()
         public mainColor = Color3.White();
-        
+
         /**
          * Color of the grid lines.
          */
         @serializeAsColor3()
         public lineColor = Color3.Black();
-        
+
         /**
          * The scale of the grid compared to unit.
          */
         @serialize()
         public gridRatio = 1.0;
-        
+
         /**
          * The frequency of thicker lines.
          */
         @serialize()
         public majorUnitFrequency = 10;
-        
+
         /**
          * The visibility of minor units in the grid.
          */
         @serialize()
         public minorUnitVisibility = 0.33;
-        
+
         /**
          * The grid opacity outside of the lines.
          */
         @serialize()
         public opacity = 1.0;
-        
+
         private _gridControl: Vector4 = new Vector4(this.gridRatio, this.majorUnitFrequency, this.minorUnitVisibility, this.opacity);
-        
+
         private _renderId: number;
         private _defines = new GRIDMaterialDefines();
         private _cachedDefines = new GRIDMaterialDefines();
-        
+
         /**
          * constructor
          * @param name The name given to the material in order to identify it afterwards.
@@ -66,14 +68,14 @@ module BABYLON {
         constructor(name: string, scene: Scene) {
             super(name, scene);
         }
-        
+
         /**
          * Returns wehter or not the grid requires alpha blending.
          */
         public needAlphaBlending(): boolean {
             return this.opacity < 1.0;
         }
-          
+
         private _checkCache(scene: Scene, mesh?: AbstractMesh, useInstances?: boolean): boolean {
             if (!mesh) {
                 return true;
@@ -112,6 +114,11 @@ module BABYLON {
                 this._defines.TRANSPARENT = true;
             }
 
+            // Fog
+            if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
+                this._defines.FOG = true;
+            }
+
             // Get correct effect      
             if (!this._effect || !this._defines.isEqual(this._cachedDefines)) {
                 this._defines.cloneTo(this._cachedDefines);
@@ -122,19 +129,19 @@ module BABYLON {
 
                 // Effect
                 var shaderName = scene.getEngine().getCaps().standardDerivatives ? "grid" : "legacygrid";
-                
+
                 // Defines
                 var join = this._defines.toString();
                 this._effect = scene.getEngine().createEffect(shaderName,
                     attribs,
-                    ["worldViewProjection", "mainColor", "lineColor", "gridControl"],
+                    ["worldViewProjection", "mainColor", "lineColor", "gridControl", "vFogInfos", "vFogColor", "world", "view"],
                     [],
-                    join, 
-                    null, 
-                    this.onCompiled, 
+                    join,
+                    null,
+                    this.onCompiled,
                     this.onError);
             }
-            
+
             if (!this._effect.isReady()) {
                 return false;
             }
@@ -144,44 +151,55 @@ module BABYLON {
 
             return true;
         }
-        
+
         public bindOnlyWorldMatrix(world: Matrix): void {
             var scene = this.getScene();
 
             this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
+            this._effect.setMatrix("world", world);
+            this._effect.setMatrix("view", scene.getViewMatrix());
         }
 
         public bind(world: Matrix, mesh?: Mesh): void {
             var scene = this.getScene();
 
-            // Matrices        
+            // Matrices
             this.bindOnlyWorldMatrix(world);
-            
+
             // Uniforms
             if (scene.getCachedMaterial() !== (<BABYLON.Material>this)) {
                 this._effect.setColor3("mainColor", this.mainColor);
                 this._effect.setColor3("lineColor", this.lineColor);
-                
+
                 this._gridControl.x = this.gridRatio;
                 this._gridControl.y = Math.round(this.majorUnitFrequency);
                 this._gridControl.z = this.minorUnitVisibility;
                 this._gridControl.w = this.opacity;
                 this._effect.setVector4("gridControl", this._gridControl);
             }
+
+            // View
+            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
+                this._effect.setMatrix("view", scene.getViewMatrix());
+            }
+
+            // Fog
+            MaterialHelper.BindFogParameters(scene, mesh, this._effect);
+
             super.bind(world, mesh);
         }
-        
+
         public dispose(forceDisposeEffect?: boolean): void {
             super.dispose(forceDisposeEffect);
         }
-        
+
         public clone(name: string): GridMaterial {
             return SerializationHelper.Clone(() => new GridMaterial(name, this.getScene()), this);
         }
 
         public serialize(): any {
-            var serializationObject = SerializationHelper.Serialize(this); 
-            serializationObject.customType = "BABYLON.GridMaterial"; 
+            var serializationObject = SerializationHelper.Serialize(this);
+            serializationObject.customType = "BABYLON.GridMaterial";
             return serializationObject;
         }
 

+ 10 - 4
materialsLibrary/materials/grid/grid.fragment.fx

@@ -13,6 +13,8 @@ uniform vec4 gridControl;
 varying vec3 vPosition;
 varying vec3 vNormal;
 
+#include<fogFragmentDeclaration>
+
 float getVisibility(float position) {
     // Major grid line every Frequency defined in material.
     float majorGridFrequency = gridControl.y;
@@ -82,13 +84,17 @@ void main(void) {
     float grid = clamp(x + y + z, 0., 1.);
     
     // Create the color.
-    vec3 gridColor = mix(mainColor, lineColor, grid);
+    vec3 color = mix(mainColor, lineColor, grid);
+
+#ifdef FOG
+    #include<fogFragment>
+#endif
 
 #ifdef TRANSPARENT
-    float opacity = clamp(grid, 0.08, gridControl.w);
-    gl_FragColor = vec4(gridColor.rgb, opacity);
+    float opacity = clamp(grid, 0.08, color.w);
+    gl_FragColor = vec4(color.rgb, opacity);
 #else
     // Apply the color.
-    gl_FragColor = vec4(gridColor.rgb, 1.0);
+    gl_FragColor = vec4(color.rgb, 1.0);
 #endif
 }

+ 11 - 0
materialsLibrary/materials/grid/grid.vertex.fx

@@ -6,12 +6,23 @@ attribute vec3 normal;
 
 // Uniforms
 uniform mat4 worldViewProjection;
+uniform mat4 world;
+uniform mat4 view;
 
 // Varying
 varying vec3 vPosition;
 varying vec3 vNormal;
 
+#include<fogVertexDeclaration>
+
 void main(void) {
+
+    #ifdef FOG
+    vec4 worldPos = world * vec4(position, 1.0);
+    #endif
+
+    #include<fogVertex>
+
     gl_Position = worldViewProjection * vec4(position, 1.0);
 
     vPosition = position;

File diff ditekan karena terlalu besar
+ 3987 - 11819
materialsLibrary/test/refs/babylon.max.js