Browse Source

minor fixes

Benjamin Guignabert 5 năm trước cách đây
mục cha
commit
c840d3b748

+ 7 - 5
src/Engines/Extensions/engine.multiRender.ts

@@ -54,17 +54,17 @@ ThinEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(textures:
     // If MSAA, we need to bitblt back to main texture
     var gl = this._gl;
 
+    var attachments = textures[0]._attachments!;
+    var count = attachments.length;
+
     if (textures[0]._MSAAFramebuffer) {
         gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
         gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
 
-        var attachments = textures[0]._attachments!;
-        var count = attachments.length;
-
         for (var i = 0; i < count; i++) {
             var texture = textures[i];
 
-            for (var j = 0; j < attachments.length; j++) {
+            for (var j = 0; j < count; j++) {
                 attachments[j] = gl.NONE;
             }
 
@@ -76,9 +76,11 @@ ThinEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(textures:
                 gl.COLOR_BUFFER_BIT, gl.NEAREST);
 
         }
-        for (var i = 0; i < attachments.length; i++) {
+
+        for (var i = 0; i < count; i++) {
             attachments[i] = (<any>gl)[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
         }
+
         gl.drawBuffers(attachments);
     }
 

+ 1 - 13
src/PostProcesses/subSurfaceScatteringPostProcess.ts

@@ -25,8 +25,7 @@ export class SubSurfaceScatteringPostProcess extends PostProcess {
         super(name, "subSurfaceScattering", ["texelSize", "viewportSize", "metersPerUnit"], ["diffusionS", "diffusionD", "filterRadii", "irradianceSampler", "depthSampler", "albedoSampler"], options, camera, samplingMode || Texture.BILINEAR_SAMPLINGMODE, engine, reusable, null, textureType, "postprocess", undefined, true);
         this._scene = scene;
 
-        const defines = this._getDefines();
-        this.updateEffect(defines);
+        this.updateEffect();
 
         this.onApplyObservable.add((effect: Effect) => {
             if (!scene.prePassRenderer) {
@@ -48,15 +47,4 @@ export class SubSurfaceScatteringPostProcess extends PostProcess {
         });
 
     }
-
-    private _getDefines(): Nullable<string> {
-        const engine = this.getEngine();
-        if (!engine) {
-            return null;
-        }
-
-        let defines = "";
-
-        return defines;
-    }
 }

+ 2 - 0
src/Shaders/ShadersInclude/fibonacci.fx

@@ -2,6 +2,8 @@
 #define GOLDEN_RATIO 1.618033988749895
 #define TWO_PI 6.2831855
 
+// Used in screen space subsurface scattering
+// http://advances.realtimerendering.com/s2018/Efficient%20screen%20space%20subsurface%20scattering%20Siggraph%202018.pdf
 vec2 Golden2dSeq(int i, float n)
 {
     // GoldenAngle = 2 * Pi * (1 - 1 / GoldenRatio).