Selaa lähdekoodia

Fix texture rescale in webgl1

David Catuhe 7 vuotta sitten
vanhempi
commit
0c5c647a1f

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 9455 - 9455
Playground/babylon.d.txt


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 7666 - 7666
dist/preview release/babylon.d.ts


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 6 - 6
dist/preview release/babylon.js


+ 5 - 4
dist/preview release/babylon.max.js

@@ -8601,7 +8601,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.1-rc-1";
+                return "3.1-rc-2";
             },
             enumerable: true,
             configurable: true
@@ -25031,6 +25031,7 @@ var BABYLON;
                 var instance = this.instances[index];
                 var serializationInstance = {
                     name: instance.name,
+                    id: instance.id,
                     position: instance.position.asArray(),
                     scaling: instance.scaling.asArray()
                 };
@@ -25285,6 +25286,9 @@ var BABYLON;
                 for (var index = 0; index < parsedMesh.instances.length; index++) {
                     var parsedInstance = parsedMesh.instances[index];
                     var instance = mesh.createInstance(parsedInstance.name);
+                    if (parsedInstance.id) {
+                        instance.id = parsedInstance.id;
+                    }
                     if (BABYLON.Tags) {
                         BABYLON.Tags.AddTagsTo(instance, parsedInstance.tags);
                     }
@@ -32555,9 +32559,6 @@ var BABYLON;
         PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport) {
             if (targetTexture === void 0) { targetTexture = null; }
             if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
-            if (!this._scene.activeCamera) {
-                return;
-            }
             var engine = this._scene.getEngine();
             for (var index = 0; index < postProcesses.length; index++) {
                 if (index < postProcesses.length - 1) {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 6 - 6
dist/preview release/babylon.worker.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 6 - 6
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 5 - 4
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -8601,7 +8601,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.1-rc-1";
+                return "3.1-rc-2";
             },
             enumerable: true,
             configurable: true
@@ -25031,6 +25031,7 @@ var BABYLON;
                 var instance = this.instances[index];
                 var serializationInstance = {
                     name: instance.name,
+                    id: instance.id,
                     position: instance.position.asArray(),
                     scaling: instance.scaling.asArray()
                 };
@@ -25285,6 +25286,9 @@ var BABYLON;
                 for (var index = 0; index < parsedMesh.instances.length; index++) {
                     var parsedInstance = parsedMesh.instances[index];
                     var instance = mesh.createInstance(parsedInstance.name);
+                    if (parsedInstance.id) {
+                        instance.id = parsedInstance.id;
+                    }
                     if (BABYLON.Tags) {
                         BABYLON.Tags.AddTagsTo(instance, parsedInstance.tags);
                     }
@@ -32555,9 +32559,6 @@ var BABYLON;
         PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport) {
             if (targetTexture === void 0) { targetTexture = null; }
             if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
-            if (!this._scene.activeCamera) {
-                return;
-            }
             var engine = this._scene.getEngine();
             for (var index = 0; index < postProcesses.length; index++) {
                 if (index < postProcesses.length - 1) {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 6 - 6
dist/preview release/viewer/babylon.viewer.js


+ 37 - 38
src/PostProcess/babylon.postProcess.ts

@@ -1,21 +1,20 @@
 module BABYLON {
     export type PostProcessOptions = { width: number, height: number };
 
-    export class PostProcess
-    {
+    export class PostProcess {
         public width = -1;
         public height = -1;
         public renderTargetSamplingMode: number;
         public clearColor: Color4;
         public autoClear = true;
         public alphaMode = Engine.ALPHA_DISABLE;
-        public alphaConstants: Color4;  
-        public animations = new Array<Animation>();  
+        public alphaConstants: Color4;
+        public animations = new Array<Animation>();
 
         /*
             Enable Pixel Perfect mode where texture is not scaled to be power of 2.
             Can only be used on a single postprocess or on the last one of a chain.
-        */ 
+        */
         public enablePixelPerfectMode = false;
 
         public scaleMode = Engine.SCALEMODE_FLOOR;
@@ -41,7 +40,7 @@
         private _shareOutputWithPostProcess: PostProcess;
         private _texelSize = Vector2.Zero();
         private _forcedOutputTexture: InternalTexture;
-       
+
         // Events
 
         /**
@@ -118,11 +117,11 @@
 
         public get outputTexture(): InternalTexture {
             return this._textures.data[this._currentRenderTextureInd];
-        }   
+        }
 
         public set outputTexture(value: InternalTexture) {
             this._forcedOutputTexture = value;
-        }   
+        }
 
         public getCamera(): Camera {
             return this._camera;
@@ -140,8 +139,8 @@
             return this._texelSize;
         }
 
-        constructor(public name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, 
-                    samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines: Nullable<string> = null, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
+        constructor(public name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
+            samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines: Nullable<string> = null, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
             if (camera != null) {
                 this._camera = camera;
                 this._scene = camera.getScene();
@@ -174,11 +173,11 @@
             if (!blockCompilation) {
                 this.updateEffect(defines);
             }
-        }    
+        }
 
         public getEngine(): Engine {
             return this._engine;
-        }        
+        }
 
         public getEffect(): Effect {
             return this._effect;
@@ -191,33 +190,33 @@
 
             return this;
         }
-        
+
         public updateEffect(defines: Nullable<string> = null, uniforms: Nullable<string[]> = null, samplers: Nullable<string[]> = null, indexParameters?: any,
-                            onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
+            onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
             this._effect = this._engine.createEffect({ vertex: this._vertexUrl, fragment: this._fragmentUrl },
                 ["position"],
                 uniforms || this._parameters,
-                samplers || this._samplers, 
+                samplers || this._samplers,
                 defines !== null ? defines : "",
                 undefined,
                 onCompiled,
                 onError,
                 indexParameters || this._indexParameters
-                );
-         }
+            );
+        }
 
         public isReusable(): boolean {
             return this._reusable;
         }
-        
+
         /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
-        public markTextureDirty() : void{
+        public markTextureDirty(): void {
             this.width = -1;
         }
 
-        public activate(camera: Camera, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): void {            
+        public activate(camera: Nullable<Camera>, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): void {
             camera = camera || this._camera;
-            
+
             var scene = camera.getScene();
             var engine = scene.getEngine();
             var maxSize = engine.getCaps().maxTextureSize;
@@ -255,17 +254,17 @@
                             this._engine._releaseTexture(this._textures.data[i]);
                         }
                         this._textures.reset();
-                    }         
+                    }
                     this.width = desiredWidth;
                     this.height = desiredHeight;
 
                     let textureSize = { width: this.width, height: this.height };
-                    let textureOptions = { 
-                        generateMipMaps: false, 
-                        generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0, 
+                    let textureOptions = {
+                        generateMipMaps: false,
+                        generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
                         generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
-                        samplingMode: this.renderTargetSamplingMode, 
-                        type: this._textureType 
+                        samplingMode: this.renderTargetSamplingMode,
+                        type: this._textureType
                     };
 
                     this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
@@ -273,7 +272,7 @@
                     if (this._reusable) {
                         this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
                     }
-                    
+
                     this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
 
                     this.onSizeChangedObservable.notifyObservers(this);
@@ -287,7 +286,7 @@
             }
 
             var target: InternalTexture;
-                        
+
             if (this._shareOutputWithPostProcess) {
                 target = this._shareOutputWithPostProcess.outputTexture;
             } else if (this._forcedOutputTexture) {
@@ -334,7 +333,7 @@
             }
             return this.width / this.height;
         }
-        
+
         public apply(): Nullable<Effect> {
             // Check
             if (!this._effect || !this._effect.isReady())
@@ -350,17 +349,17 @@
             this._engine.setAlphaMode(this.alphaMode);
             if (this.alphaConstants) {
                 this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
-            }            
+            }
 
             // Texture            
-            var source: InternalTexture;                        
+            var source: InternalTexture;
             if (this._shareOutputWithPostProcess) {
                 source = this._shareOutputWithPostProcess.outputTexture;
             } else if (this._forcedOutputTexture) {
                 source = this._forcedOutputTexture;
             } else {
                 source = this.outputTexture;
-            }            
+            }
             this._effect._bindTexture("textureSampler", source);
 
             // Parameters
@@ -384,7 +383,7 @@
         }
 
         public dispose(camera?: Camera): void {
-            camera = camera || this._camera;            
+            camera = camera || this._camera;
 
             this._disposeTextures();
 
@@ -392,12 +391,12 @@
                 let index = this._scene.postProcesses.indexOf(this);
                 if (index !== -1) {
                     this._scene.postProcesses.splice(index, 1);
-                }                
+                }
             } else {
                 let index = this._engine.postProcesses.indexOf(this);
                 if (index !== -1) {
                     this._engine.postProcesses.splice(index, 1);
-                }         
+                }
             }
 
             if (!camera) {
@@ -407,7 +406,7 @@
 
             var index = camera._postProcesses.indexOf(this);
             if (index === 0 && camera._postProcesses.length > 0) {
-                this._camera._postProcesses[0].markTextureDirty(); 
+                this._camera._postProcesses[0].markTextureDirty();
             }
 
             this.onActivateObservable.clear();
@@ -415,6 +414,6 @@
             this.onApplyObservable.clear();
             this.onBeforeRenderObservable.clear();
             this.onSizeChangedObservable.clear();
-        }          
+        }
     }
 }

+ 2 - 6
src/PostProcess/babylon.postProcessManager.ts

@@ -38,7 +38,7 @@
 
             this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
         }
-        
+
         public _rebuild(): void {
             let vb = this._vertexBuffers[VertexBuffer.PositionKind];
 
@@ -48,7 +48,7 @@
             vb._rebuild();
             this._buildIndexBuffer();
         }
-        
+
         // Methods
         public _prepareFrame(sourceTexture: Nullable<InternalTexture> = null, postProcesses: Nullable<PostProcess[]> = null): boolean {
             let camera = this._scene.activeCamera;
@@ -67,10 +67,6 @@
         }
 
         public directRender(postProcesses: PostProcess[], targetTexture: Nullable<InternalTexture> = null, forceFullscreenViewport = false): void {
-            if (!this._scene.activeCamera) {
-                return;
-            }
-
             var engine = this._scene.getEngine();
 
             for (var index = 0; index < postProcesses.length; index++) {