tres
tres copied to clipboard
Library override the DPR setting in autonomy without chances to clamp / control it
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:
- 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.
- 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
- [X] I agree to follow this project's Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] The provided reproduction is a minimal reproducible example of the bug.