[SOLVED] Highlight posteffect broken in Engine 1.66

Hi everyone,

I have an application where I use some posteffects to achieve a sort of highlight effect to highlight an object.
This effect seems to have issues since the 1.66 engine version where it seems like the object is having Z-fighting issues.

To give some context how I achieve this effect:

  • There is a posteffect on the camera, in this case to edit the brightness and contrast to make the image washed out.
  • I created another rendering layer (WorldNoPost).
  • There is a script on the camera that sets this new layer to the amera.disablePostEffectsLayer.
  • The highlighted object is added to this new layer which should ignore the posteffect.

I have created an example project to showcase the issue:
https://playcanvas.com/editor/scene/1905900

Here is the desired result in 1.65.5 (Previous Minor):

And here is how it looks in 1.66.3:

It looks like there is some Z-fighting with the object that needs to be highlighted.
If I remove the highlighted object from the normal ‘World’ layer, it is still correct in 1.65.5, but in 1.66 it just dissapears in the Z-fighting like pattern:

Hopefully someone can help me resolve this issue. (Or give me an idea if there’s another way to achieve this effect?)

Thanks in advance for the help!

Try this in PostTest.js

var PostTest = pc.createScript('postTest');

// initialize code called once per entity
PostTest.prototype.initialize = function () {
    this.entity.camera.disablePostEffectsLayer = this.app.scene.layers.getLayerByName('WorldNoPost').id;
    this.brightnessPost = this.entity.script.brightnessContrast;
    this.layer = this.app.scene.layers.getLayerByName('WorldNoPost');
    this.layer.clearDepthBuffer = true;
};


PostTest.prototype.update = function (dt) {
    //flip post effect
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.brightnessPost.enabled = !this.brightnessPost.enabled;
        this.layer.clearDepthBuffer = !this.layer.clearDepthBuffer;
    }
};
1 Like

Yes, this worked to get the desired result again.

Thank you for the help!

1 Like