0beqz / realism-effects

SSGI, Motion Blur, TRAA - Effects to enhance your three.js scene's realism
https://realism-effects-obeqz.vercel.app/
MIT License
1.44k stars 70 forks source link

Trailing effect when rotating camera #6

Open vis-prime opened 1 year ago

vis-prime commented 1 year ago

continuing this thread from twitter https://twitter.com/vis_prime/status/1632602124269023233?s=20

I'm noticing trails being formed which does not happen on the demo page

https://user-images.githubusercontent.com/119810373/223689810-29465e17-b74d-4a98-abb4-fe8a0635d5d6.mp4

vis-prime commented 1 year ago

Ok found the exact reason !

in the render loop camera.updateMatrixWorld() needs to be called, no more trails now

https://user-images.githubusercontent.com/119810373/223692107-40a89588-d81b-4dcf-967c-b1e9e06a5139.mp4

the result is quite noisy & shadows are blocky , what could be the reason for that ?

demo : https://vis-prime.github.io/explore-vanilla-drei/?scene=RealismEffects code : https://github.com/vis-prime/explore-vanilla-drei/blob/main/demos/realismEffectsDemo.js

0beqz commented 1 year ago

Do you get similar results when drag and dropping that model into the demo scene? Otherwise increase the denoiser's aggressivity by increasing denoiseIterations, denoiseSpecular and denoiseDiffuse. Maybe it could also be an issue with the temporal reprojection pass, what happens if you increase the blend factor of it to a higher value like 0.95?

Also, calling updateMatrixWorld() on the camera should only be done if you have matrixAutoUpdate disabled in your scene like it is the case in the demo scene - is it also disabled in your scene, as I'm wondering if the trailing only happens if you don't call updateMatrixWorld?

vis-prime commented 1 year ago

on the drag and drop page i don't get the same artifacts

https://user-images.githubusercontent.com/119810373/224096805-0be6dcc4-4d6e-4637-bf60-0e41a26c763b.mp4

So just to break down everything here are all the special steps I took compared to a generic project

Renderer init

 renderer = new WebGLRenderer({
    powerPreference: "high-performance",
    premultipliedAlpha: false,
    stencil: false,
    antialias: false,
    alpha: false,
    preserveDrawingBuffer: true,
  })
  renderer.setPixelRatio(Math.min(1.5, window.devicePixelRatio))
  renderer.setSize(window.innerWidth, window.innerHeight)
  renderer.outputEncoding = sRGBEncoding
  renderer.toneMapping = ACESFilmicToneMapping
  renderer.autoClear = false

Postprocessing stack first pass: velocityDepthNormalPass second pass: SSGI/SSR/SSGDI ,TRAA ,motionBlur

If GI is off I use a renderPass so traa and motionblur can run independently (also console.log prints composer.passes any time you change an option)

Exr loader const exrLoader = new EXRLoader().setDataType(FloatType)

render loop camera.updateMatrixWorld()

Anything obvious i've missed ? I also haven't done the offscreen canvas thing and did not add any matrixAutoUpdate false anywhere

demo same as before

screenshots SSGI ssgi SSGDI ssdgi SSR ssr

0beqz commented 1 year ago

Interesting, I'll check your demo when I have time. Do you get different results when not using TRAA and motion blur?

I'm also wondering if the device pixel ratio could play a role as you get some odd pattering in the images.

vis-prime commented 1 year ago

Screen goes black or frame freezes when i use SSGI with TRAA or motion blur, something definitely went wrong

i'll re-do the setup and use your example code as starting point , I'll report back with the findings

ss

does anything feel off ?

vis-prime commented 1 year ago

Update

Things i noticed are camera.updateMatrixWorld is required on every frame to prevent the trails

I removed the scaling logic (since the model is built to scale) and i'm getting this random tearing effect

Using v1.0.14 demo code

https://user-images.githubusercontent.com/119810373/225716719-d7d58bcd-0843-4d20-bd1e-08b2b9e931e9.mp4

0beqz commented 1 year ago

Thanks. So I've added camera.updateMatrixWorld() to the velocity pass so that shouldn't be an issue anymore. The problem was, that without using a RenderPass, the camera's matrix world would still be outdated when rendering the velocity in the velocity pass causing that trailing. I recently added in the readme that without using a RenderPass, SSGI has to be in its own effect since that caused some confusion.

I'll try to look into that horizontal tearing, not too sure what could be causing that..

vis-prime commented 1 year ago

updated to latest

camera.updateMatrixWorld() no longer required

the random tearing issue still exists (only clue is that once I removed the scaling logic the models became very small compared to before)

this issue can be closed then , I'll make new one for the other issue I found