From 12d67f0cac2f1d64d07dd62e2490688db3343b40 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 30 Nov 2023 23:42:42 +0530 Subject: [PATCH] fixes.js --- src/webgl/p5.RendererGL.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index 29f8c3f6f6..ac76ac23d0 100644 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -554,6 +554,7 @@ p5.RendererGL = class RendererGL extends p5.Renderer { this.executeRotateAndMove = false; this.specularShader = undefined; + this.diffusedShader = undefined; this._defaultLightShader = undefined; this._defaultImmediateModeShader = undefined; this._defaultNormalShader = undefined; @@ -1928,16 +1929,20 @@ p5.RendererGL = class RendererGL extends p5.Renderer { let smallWidth = 200; let width = smallWidth; let height = Math.floor(smallWidth * (input.height / input.width)); - newFramebuffer = this._pInst.createFramebuffer(); + newFramebuffer = this._pInst.createFramebuffer({ + width, height, density: 1 + }); // create framebuffer is like making a new sketch, all functions on main // sketch it would be available on framebuffer - newFramebuffer.draw(() => { - let irradiance = this._pInst.createShader( + if (!this.diffusedShader) { + this.diffusedShader = this._pInst.createShader( defaultShaders.imageLightVert, defaultShaders.imageLightDiffusedFrag ); - this._pInst.shader(irradiance); - irradiance.setUniform('environmentMap', input); + } + newFramebuffer.draw(() => { + this._pInst.shader(this.diffusedShader); + this.diffusedShader.setUniform('environmentMap', input); this._pInst.noStroke(); this._pInst.rectMode(constants.CENTER); this._pInst.noLights(); @@ -1966,9 +1971,10 @@ p5.RendererGL = class RendererGL extends p5.Renderer { const size = 512; let tex; const levels = []; - const framebuffer = this._pInst.createFramebuffer(); + const framebuffer = this._pInst.createFramebuffer({ + width: size, height: size, density: 1 + }); let count = Math.log(size) / Math.log(2); - framebuffer.pixelDensity(1); if (!this.specularShader) { this.specularShader = this._pInst.createShader( defaultShaders.imageLightVert,