Skip to content

Commit

Permalink
fix rect z, w, native viewport (#17528)
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e authored Aug 12, 2024
1 parent 3b8a65e commit a039349
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions editor/assets/default_renderpipeline/builtin-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion native/cocos/renderer/pipeline/custom/NativeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit a039349

Please sign in to comment.