From a03934935e0e6f18d0e3563d51a55a551d164c00 Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Mon, 12 Aug 2024 17:44:46 +0800 Subject: [PATCH] fix rect z, w, native viewport (#17528) --- .../default_renderpipeline/builtin-pipeline.ts | 12 ++++++++---- .../renderer/pipeline/custom/NativeExecutor.cpp | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/editor/assets/default_renderpipeline/builtin-pipeline.ts b/editor/assets/default_renderpipeline/builtin-pipeline.ts index d18e0f5d68e..cf047889823 100644 --- a/editor/assets/default_renderpipeline/builtin-pipeline.ts +++ b/editor/assets/default_renderpipeline/builtin-pipeline.ts @@ -648,8 +648,10 @@ if (rendering) { this._viewport.left = Math.floor(camera.viewport.x * width); this._viewport.top = Math.floor(camera.viewport.y * height); - this._viewport.width = Math.max(Math.floor(camera.viewport.z * width), 1); - this._viewport.height = Math.max(Math.floor(camera.viewport.w * height), 1); + // Here we must use camera.viewport.width instead of camera.viewport.z, which + // is undefined on native platform. The same as camera.viewport.height. + this._viewport.width = Math.max(Math.floor(camera.viewport.width * width), 1); + this._viewport.height = Math.max(Math.floor(camera.viewport.height * height), 1); this._clearColor.x = camera.clearColor.x; this._clearColor.y = camera.clearColor.y; @@ -1285,8 +1287,10 @@ if (rendering) { // Prepare camera viewport this._viewport.left = Math.floor(camera.viewport.x * width); this._viewport.top = Math.floor(camera.viewport.y * height); - this._viewport.width = Math.max(Math.floor(camera.viewport.z * width), 1); - this._viewport.height = Math.max(Math.floor(camera.viewport.w * height), 1); + // Here we must use camera.viewport.width instead of camera.viewport.z, which + // is undefined on native platform. The same as camera.viewport.height. + this._viewport.width = Math.max(Math.floor(camera.viewport.width * width), 1); + this._viewport.height = Math.max(Math.floor(camera.viewport.height * height), 1); // MSAA const enableMSAA = !disableMSAA && this._cameraConfigs.enableMSAA; diff --git a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp index 61b06d07176..acde3ec5a94 100644 --- a/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp +++ b/native/cocos/renderer/pipeline/custom/NativeExecutor.cpp @@ -426,7 +426,7 @@ struct RenderGraphVisitor : boost::dfs_visitor<> { vp.height = pass.height; } // scissor - gfx::Rect scissor{0, 0, vp.width, vp.height}; + gfx::Rect scissor{vp.left, vp.top, vp.width, vp.height}; // render pass {