Is there a way to do multiple shader passes?

Hi,

I’m currently trying to implement an outline shader as the one we currently use is too performance intensive on Retina screens!

I found a shader on the web that does not need to read a fullscreen texture multiple times per frame but simply displace the model by its normals along with front face culling and some other stuff. I assume this would yield better performance.

Alas, this shader requires two passes, one rendering the model and one displacing it to draw the outline, and I don’t see how I could do this in Playcanvas so any help would be appreciated!

Thanks in advance!

I think your best bet here would be to create an additional camera with higher priority, so that it renders on top. Disable any clears on it. Meshes that you need outlines on would be in the main camera, but additional add them to this camera. I think you’d need to clone the entities and change their materials to the outline pass material.

1 Like

Actually, if you clone the entities as I suggested, you don’t need additional camera. Just have additional layer on the same camera that renders perhaps after all opaque layers. And add those cloned entities with outline hull shader to it.

2 Likes

Yes, I managed to make it work, thanks a lot !

1 Like

Hey, I’m facing a similar issue: I’m doing a post-processing effect in PlayCanvas that requires multiple shader passes, and I’m not entirely sure how to go about this. However, I am pretty sure a workaround like mentioned above would not work in my case.

I noticed there has been some work on improving the render pass pipeline: https://github.com/playcanvas/engine/issues/4271
So was hoping perhaps it would be more feasible to do this now.

Anyone know how to go about doing multiple shader passes now?

Post-processing effects are a special case that already handles multiple passes, perhaps that would work for you? See for example a bloom filter:

3 Likes