tres icon indicating copy to clipboard operation
tres copied to clipboard

Library override the DPR setting in autonomy without chances to clamp / control it

Open dghez opened this issue 7 months ago • 2 comments

I noticed that Tres set the DPR (see code) completely in autonomy without any way to control that, imho is conceptually wrong for couple of reasons:

  1. The dev should be in charge to decide the DPR or at least be able to clamp. For example if the app is opened on a 3DPR mobile is gonna run at 3, that is completely insane.
  2. The app should not change the dpr on resize without consent. I noticed it because i was setting manually in a range
  const dpr = MathUtils.clamp(window.devicePixelRatio, 1, 1.4) 
 renderer.value.setPixelRatio(dpr)

but on resize switching between monitors on my macbook was set back to 2 due the useDevicePixelRatio hook. This second point tho depends on the first one. If We decide to let the app handle the resize, it's 100% needed to add a clamp on that.

This can lead to some big issues, both perf wise and effect wise. I notice the "issue" because i was doing some effect in screen-space, where my resolution wasn't matching my DPR vec2 st = gl_FragCoord.xy / (gResolution * gDpr);

My take on this is that the library can take care of the DPR but at least give the user some way to control, like they don in r3f where you can set dpr=[low, high] that clamps it :)

Reproduction


Steps to reproduce


System Info

----

Used Package Manager

npm

Code of Conduct

dghez avatar Jul 09 '24 08:07 dghez