playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF

Home Page:https://playcanvas.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Camera non-default viewport size ignores camera clear color

MarlonLam opened this issue · comments

Description

When changing the camera viewport from default (0, 0, 1, 1) to non-default values e.g. (0.01, 0, 1, 1), the camera's clear color is ignored.

Test URL

Test project: https://playcanvas.com/editor/scene/1980662

Screenshots

(0, 0, 1, 1):
image

(0.01, 0, 1, 1):
image

Platform

Tested in Edge

Steps to Reproduce

  1. Set camera viewport size to something other than (0, 0, 1, 1)
  2. Launch

Additional Notes

From my own digging around, I found a property assignment for "clearColor":

if (!firstRenderAction || !camera.camera.fullSizeClearRect) {
options.clearColor = renderAction.clearColor;
options.clearDepth = renderAction.clearDepth;
options.clearStencil = renderAction.clearStencil;
}
renderer.renderForwardLayer(camera.camera, renderAction.renderTarget, layer, transparent,
shaderPass, renderAction.viewBindGroups, options);

But in "renderForwardLayer" function, the property read is "clearColors":

const clearColor = options.clearColors ?? false;
const clearDepth = options.clearDepth ?? false;
const clearStencil = options.clearStencil ?? false;
if (clearColor || clearDepth || clearStencil) {
this.clear(camera, clearColor, clearDepth, clearStencil);
}

Thanks for this, easy to fix if you just point it out to us!