Skip to content

Conversation

Pheo
Copy link

@Pheo Pheo commented Mar 26, 2025

This PR takes over @CedricGuillemet's #1477
Comments from CedricGuillemet#9 addressed before opening this for review. Added comments for the ones which I haven't addressed.

RenderDoc shows filterstack correctly swapping between render targets for a 3-iterations (6 pass) blur.:
image

Will need to do abit of digging on weights to match how it looks on browser. Applying filter blur to couple of items in experience.js:
image

Also, on Babylon.js side, have raised a PR adding filter to context.
BabylonJS/Babylon.js#16424

@Pheo Pheo changed the base branch from master to CanvasTest March 26, 2025 14:36
@Pheo Pheo force-pushed the BNCanvasCompositeBlur branch from 1b849cf to 13a3b8e Compare March 31, 2025 02:39
@Pheo Pheo marked this pull request as ready for review March 31, 2025 06:56

for (int i = 1; i <= 6; i++)
{
vec2 offset = u_direction.xy * float(i); // TODO: normalize against u_viewSize.xy
Copy link
Author

@Pheo Pheo Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I'm not setting u_viewSize between filter passes. Or any uniforms for that matter (outside of the ones explicitly specified in setUniform. Will fix.

EDIT: After abit more reading, I think I understand how to scale blur strength taking into account viewSize. WIP updated fragment shader.

RaananW pushed a commit to BabylonJS/Babylon.js that referenced this pull request Apr 1, 2025
@Pheo Pheo force-pushed the BNCanvasCompositeBlur branch from e5cd68d to 7ff2c0c Compare April 1, 2025 13:59
@Pheo
Copy link
Author

Pheo commented Apr 2, 2025

Have just pushed a couple of fixes. Notable changes/fixes include:

  • Always clear released framebuffers
  • Bind canvas framebuffer before applying filter stack
  • Fixed up blur shader to account for u_viewSize + u_halfTexel
  • Wired up remaining glnv__* methods to draw with filterstack

@Pheo Pheo force-pushed the BNCanvasCompositeBlur branch from 2d2dbd4 to 287ff01 Compare April 3, 2025 05:57
@Pheo Pheo changed the title nanovg Compositor nanovg Compositor + context.filter blur Apr 3, 2025
@Pheo
Copy link
Author

Pheo commented Apr 3, 2025

I've just noticed that Gradient Text is broken in this branch. Have narrowed it down to sometime before the "filter stack PoC" commit.
CanvasTest...Pheo:BabylonNative:d1223cb72c1fd91bbb5c40ef9f6c9936cf7ac22d

EDIT: Oh, it was just missing the 2nd texture in glnvg__triangles. Fixed!
image
EDIT2: Need to pre-multiply alpha to get rid of the dark edges

@Pheo Pheo requested a review from CedricGuillemet April 3, 2025 10:55
@Pheo Pheo force-pushed the BNCanvasCompositeBlur branch 2 times, most recently from 62c668f to d514391 Compare April 4, 2025 07:15
@Pheo
Copy link
Author

Pheo commented Apr 7, 2025

Have pulled in CanvasTest. And also added the texture management cleanup? from #1491 for FrameBufferPool textures

@CedricGuillemet CedricGuillemet merged commit f222e21 into BabylonJS:CanvasTest Apr 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants