I have a need to post-process some primitives, but not all. I found that the examples in sandcastle not involved to it. The only scene is to hover or click one entity/viewmodel, which can be post-process.
Is there any methods to post-process some specific primitives, such as the primitivies in the viewport, but not effect the other primitives in other layers?
thank you for your apply.
Hi @ly15927086342,
I’m not sure what you mean by “layers” - can you clarify?
In general though, post processing effects are typically full-screen. (They work by taking the framebuffer that would have been shown on screen, and using it as an input to a render pass which just draws a full-screen quad).
You could potentially achieve the effect you really want, but it would be pretty advanced. This is an outline of the sort of things you’d have to do (I haven’t looked into the specifics of the Cesium API, but can if you’re interested):
- Render everything in the scene to an offscreen frame buffer
- Render just the entities you want to post-process to another off screen frame buffer, attaching and using the depth buffer from pass 1. In this pass, you really just need to render your entities as a mask.
- Write a custom post-process fragment shader that samples the mask frame buffer from pass 2. For pixels in the mask, do your post processing. For pixels not in the mask, write out the color from pass 1.
I think that may be possible using Scene#requestRender / Scene#render, and Scene.context to create the framebuffers and such. Technically, Scene.context is not part of the public API… so use with caution, if you choose to.
Honestly, this whole idea could be a potential feature request for us to support, to make it possible and easier for users to apply post-effects to specific entities.
The much easier way would be to hook into the system Cesium already exposes with czm_selected, as you pointed out exists. It’s a little limited but I’m curious why you can’t make it work?
Hi @mzschwartz5 ,
My case is that, in my application, there are several layers to express different entities, such as those osm entities in openstreet map. They are rendered well.
Now, I need add a new Layer, which ara raster tiles coming from heatmap of vehicle trajectory in level 16. And I want to post-process blur these tiles only, not to effect other entites such as road in other layers.
I have tried the czm_selected by expend a get interface of pickIds of Primitive class, which mentioned by Shaders and selected primitives in PostProcessStage - #3 by Martin_Novak . It does worked but I found that if entities like roads overlap with the heatmap tile, roads will also be blurred, which is not my intention. It seems that czm_selected is a mask mark to target primitive in pixel level, which will effect other overlapping entites. Is my understanding right?
I’m interested in your solution, can it solve my situation? If then, can you show me some demo how to deal with the overlap situation.
Thank you for your apply! Best wishes.