diff --git a/public/project/floors/MT50.js b/public/project/floors/MT50.js index 3f4465e..79bc573 100644 --- a/public/project/floors/MT50.js +++ b/public/project/floors/MT50.js @@ -32,7 +32,7 @@ main.floors.MT50= ], "9,13": [ "在你刚进入苍蓝之殿时,你只能先前往左下角部分(本地图的左面),右下角暂时不能前往。注意往上走往左依然可以进入左下角,不要只盯着这个地图的左边不放。", - "注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上" + "注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上。以及由于不可抗力,修改游戏缩放后需要刷新页面才能使光照正常。" ], "9,1": [ "建议优先点出学习技能,对于特定场景将会非常有帮助", diff --git a/src/core/fx/shadow.ts b/src/core/fx/shadow.ts index 5daf1c7..4cd51d0 100644 --- a/src/core/fx/shadow.ts +++ b/src/core/fx/shadow.ts @@ -15,7 +15,7 @@ const MAX_LIGHT_NUM = 5; /** 阴影层的Z值 */ const Z_INDEX = 55; // 我也不知道这个数怎么来的,试出来是这个,别动就行 -const FOVY = Math.PI / 1.86; +const FOVY = Math.PI / 2; const ignore: Set = new Set([660]); interface LightConfig { @@ -70,7 +70,7 @@ function addLightFromBlock(floors: FloorIds[], block: number, config: LightConfi }) } -Mota.require('var', 'loading').once('coreInit', () => { +Mota.require('var', 'hook').once('reset', () => { Shadow.init(); addLightFromBlock( core.floorIds.slice(61), @@ -412,7 +412,7 @@ export class Shadow { const polygons = calMapPolygons(this.floorId, this.immerse, nocache); const res: number[] = []; - const ratio = core.domStyle.scale * devicePixelRatio; + const ratio = devicePixelRatio * core.domStyle.scale; const m = core._PX_ * ratio * 2; polygons.forEach(v => { @@ -768,8 +768,8 @@ export class Shadow { const gl = Shadow.gl; const ratio = core.domStyle.scale * devicePixelRatio; const cameraMatrix = mat4.create(); - mat4.lookAt(cameraMatrix, [light.x * ratio, light.y * ratio, core._PX_ * 2], [light.x * ratio, light.y * ratio, 0], [0, 1, 0]); - + mat4.lookAt(cameraMatrix, [light.x * ratio, light.y * ratio, core._PX_ * 2 * ratio], [light.x * ratio, light.y * ratio, 0], [0, 1, 0]); + const size = core._PX_ * ratio * 2; gl.viewport(0, 0, size, size); const framebuffer = Shadow.buffer.depth.framebuffer[index]; @@ -870,7 +870,7 @@ export class Shadow { gl.deleteTexture(this.texture.blur); gl.deleteTexture(this.texture.color); gl.deleteTexture(this.texture.depth); - + this.texture.blur = this.create2DTexture(canvas.width); this.texture.color = this.create2DTexture(canvas.width); this.texture.depth = this.create3DTexture(canvas.width, MAX_LIGHT_NUM); @@ -887,6 +887,7 @@ export class Shadow { const gl = this.gl; if (!isWebGL2Supported()) return; gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + const ratio = core.domStyle.scale * devicePixelRatio; // program const depth = createProgram(gl, depthVertex, depthFragment); @@ -938,7 +939,7 @@ export class Shadow { // Matrix const lightProjection = mat4.create(); - mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * 2); + mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * ratio); this.martix = { projection: lightProjection } @@ -978,6 +979,17 @@ export class Shadow { } } + static resize() { + if (this.martix) { + const ratio = core.domStyle.scale * devicePixelRatio; + const lightProjection = mat4.create(); + mat4.perspective(lightProjection, FOVY, 1, 1, core._PX_ * ratio); + this.martix = { + projection: lightProjection + } + } + } + /** * 清除一些关键缓冲区的内容,当且仅当图块变化或者切换地图时调用 */