Can I use chromatic aberration on a single mesh as opposed to the whole canvas?

I’ve used these post processing effects, but I want them to only occur around an enemy in a top down view, not the entire canvas. Any ideas?

from docs here:
https://doc.babylonjs.com/how_to/using_depth-of-field_and_other_lens_effects#how-to-use-depth-of-field-and-other-lens-effects

Hello and welcome,

Unfortunately no as this is a postprocess.
But if that works for you, you can maybe use 2 scenes? render your mesh+pp in the first one and everything else in the second?

interesting if I created two scenes, could I render both at once on the same canvas?

Absolutely :slight_smile:
https://www.babylonjs-playground.com/#1IZVFS#19

5 Likes

That is SO strange, DK! What the heck? How the heck? (Wingy pinches himself to check if awake.)

Oh yeah, hi craql and welcome aboard! Interesting idea/challenge!

Now I gotta go lock myself in the basement for a week until i grapple what the hell Deltakosh just showed us, and build a game plan for future experiments/abuse of it. :slight_smile: The FPS is solid as a rock! heh.

Lol!!

Thanks Delta,
I noticed a substantial drop in fps when rendering two scenes, is that to be expected?

but you render from TWO CAMERAS! its possible render 2 scenes with one camera? e.g i need render 2 scenes from vr camera. first scene for world and second for vr gui placed in world from second scene because if i render vr gui attached to boxBehavior in main scene with postprocessing its slow down render

Hi C, sorry to butt-in, but… adjust the value in playground line 30. Values around 1000 will give you better fps readings, and values < 20… unpredictable. This type of scene… “messes-with” the playground fps meter. (Actually, it disconnects the fps meter as soon as that setTimeout runs.)

That was a Wingnut comedy attempt… cuzzz… I played with line 30, and thought about setTimeout running only ONCE (opposite of setInterval)… and then I panned the camera around violently, and the fps didn’t even SLIGHTLY “flutter”/change-val… and then I said… “Hey Wingnut… you are being fooled”.

The fps is disconnected after it is written-to once or maybe a few times. Then it freezes at its last-displayed value, and is never updated again.

It is because…

engine.runRenderLoop(function () {
	scene1.render();
        scene2.render();
});

… replaces engine’s NORMAL/default .runRenderLoop()… with a new “TWO scoops of ice cream” -version. When we installed that new overload function, we accidentally disabled refreshFPS() or some similar-named system. :slight_smile:

FPS - rock-solid… you bet. It’s shut off sometime around scene.onReadyObserve :slight_smile:
Good fun, huh? If I were energetic, I might repair this PG’s FPS-updater… but… no… too lazy atm… sorry. Still, good fun with FPS, eh?

Deltakosh knew. I know he did. I think he and his co-workers… had some intra-office bets placed… “I bet someone asks about the slow FPS”. :smiley: I ALMOST asked about it in my last post… but then I figged the fun. :slight_smile:

Well it depends on the scene :wink: But as @Wingnut this is more a problem with the fps meter than the real perf of the scene

In this case I recommend using one scene but instead using renderinggroup ids: https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups

DK, @craql 's original challenge… was to activate a post-process on a specific group of mesh… when camera is above them.

Will renderingGroup ID’s be useful, here? Can Cragl add a camera.beta-dependent post-process on a certain GROUP-id of mesh, while other mesh in the scene (other rendering groups) remain post-process-free?

I’m not sure if renderingGroups will solve the “post process only on SOME mesh and only if camera.beta < .707” -challenge. Thinkin’. (yikes, huh?)

For @craql question the multi scene is the answer :slight_smile:
I was more answering @kvasss question (please do not hack thread ;))

oh, yuh, sorry about that. I need to pay attention better. Clean off my mess, as wanted. I was on a goose chase. :slight_smile:

no worry buddy!

I’m only about half-way thru my basement time with that playground. I accidentally thought about 100 scenes… each with a different post-process, MAYBE each with a different viewport (6 viewports on-canvas at same time … scrollable)… to “show-off” our “Coolest Post-Processes” and let user select one of the viewports… and make it go full-canvas… and back to “thumbnailed” again (back to scrolling viewport menu-o-post-procs).

SO demented! I knew this would happen with that PG. I went dreaming and drooling… off-topic and really… BJS-abusive. I have no life. :slight_smile:

(Wingy quickly codes-up the GUI2d viewport control) (yeeeah, right). :slight_smile:

2 Likes

thanks @Wingnut and @Deltakosh for diving into this. I also appreciate some knowledge on how not to be fooled by the fps meter.

@Wingnut if you do go down a path of prototyping a multi-scene singular-object post processing playground I’d love to see it as although I now understand in concept how to pull this off, as working example from a pro would help me work through this.

1 Like

:slight_smile: I’m no “pro”, unfortunately. I’ve just been standing-around talking aimlessly on the forum… for the same amount of time that a LONG TERM pro MIGHT do. In other words, I’m only old enough and programmer-smelly enough… to be a pro. Not smart enough, though. :slight_smile:

I hardly ever do post-processes. Maybe some highlights, glows, lensFlares, and GodRays (VLS), but that’s about it. I went searching playgrounds so i could see what a chromaticAberration IS or LOOKS LIKE… found one broken playground… working on getting it fixed.

Let’s invite EVERYONE to help with this. There’s some post-process gods around here… I hope they climb-aboard. But I’m a little worried about this idea of “only aberrate when seen from above” - thing. We obviously have two scenes, one mesh in each, being rendered to the same canvai. So, hmm… same mesh in both scenes, one scene with aberration PP, one without.

I guess… hmm… perhaps add the 2nd aberrated scene atop the canvas… when camera.beta < .707 (arcRotateCam)? Or… maybe just turn ON the PP in scene 2… when camera.beta says “go”, and turn-off again when not wanted? I dunno.

Ok, I just went and read a bit about CAPP (chromatic-ab post-proc)… distorted color focal points caused by light passing thru glass (or something like that).

I HAVE seen this effect… usually when I wake in the middle of the night and turn-on that bathroom light. FOOM! - wide-spectrum photon explosion… IN YOUR FACE, bro. :slight_smile: Usually, I am soon-able to re-locate my “point of focus” in those cases. :wink: “pressing matters”.