Skip to content

Fix postprocessing not working#312

Closed
mommysgoodpuppy wants to merge 7 commits intopmndrs:mainfrom
mommysgoodpuppy:main
Closed

Fix postprocessing not working#312
mommysgoodpuppy wants to merge 7 commits intopmndrs:mainfrom
mommysgoodpuppy:main

Conversation

@mommysgoodpuppy
Copy link
Copy Markdown
Contributor

@mommysgoodpuppy mommysgoodpuppy commented Mar 25, 2025

fixes #299

Does create a rendering bug on selection outlines. There's a simpler fix without that but it would disable effects in editor view so I'd prefer this if the outlines can be fixed. Edit: fixed 👏

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 25, 2025

🦋 Changeset detected

Latest commit: c0cd84a

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "@triplex/electron" specified in the `fixed` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.
The package or glob expression "@triplex/editor" specified in the `fixed` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2025

CLA assistant check
All committers have signed the CLA.

const originalRender = gl.render;
let isMounted = true;
gl.render = function (scene, camera, ...args) {
if (isMounted && activeState === "editor" && activeCamera) {
Copy link
Copy Markdown
Collaborator

@itsdouges itsdouges Mar 25, 2025

Choose a reason for hiding this comment

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

Ah interesting. This seems like hacks 😄 — what was happening without the fix? What was the thought process for fixing it this way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the original function that was here was manually calling gl render, which inherits the render pipeline that effect composer modifies, likely doing disabling autoclear for some effects, which is why when theres an effectcomposer the editor view just freezes

useFrame(({ gl, scene }) => {
    if (activeCamera) {
      gl.render(scene, activeCamera);
    }
  }, 1);

so instead of that my fix doesn't try to bypass the r3f render loop we just patch the camera in to be the editor camera

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah interesting, smart idea! Lets send it. Will import the changes.

… force enable autoClear in editor mode to fix outline blending artifact, does not break postprocessing effects
@itsdouges
Copy link
Copy Markdown
Collaborator

itsdouges commented Mar 26, 2025

@mommysgoodpuppy I've rebased and pushed to your remote so I can import this, merge commits don't work with the tooling.

I'm going to add this behind a feature gate and add some comments, then merge.

Edit: I've opened standard components and it doesn't seem to be working with them. Can you confirm? My guess is it's picking up the wrong gl.render call.

@itsdouges itsdouges changed the title fix conflict with @react-three/postprocessing #299 Fix conflict with @react-three/postprocessing #299 Mar 27, 2025
@itsdouges itsdouges changed the title Fix conflict with @react-three/postprocessing #299 Fix conflict with @react-three/postprocessing Mar 27, 2025
@itsdouges itsdouges changed the title Fix conflict with @react-three/postprocessing Fix postprocessing not working Mar 27, 2025
@itsdouges
Copy link
Copy Markdown
Collaborator

itsdouges commented Mar 27, 2025

Was given a suggestion maybe setting the current use frame to 0.5 could work so it renders before post processing.

0.5 = take over render loop, and do so before EffectComposer's default

I've updated an example to have postprocessing. Give it a whirl and let's figure this thing out 🙏

@itsdouges
Copy link
Copy Markdown
Collaborator

Great thanks will import this and send it, if there's edge cases that come up I'll turn the feature gate off and we can fix it.

triplex-bot pushed a commit that referenced this pull request Mar 28, 2025
adeira-source-id: f61dd89

Co-authored-by: mommysgoodpuppy <theelectronicfreezer@gmail.com>
@itsdouges
Copy link
Copy Markdown
Collaborator

This has been merged and will go out in the next cut! Cheers @mommysgoodpuppy.

Commit: f147379

@itsdouges itsdouges closed this Mar 28, 2025
itsdouges added a commit that referenced this pull request Sep 23, 2025
Co-authored-by: mommysgoodpuppy <theelectronicfreezer@gmail.com>
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.

@react-three/postprocessing editor camera conflict

3 participants