Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdaptiveDpr min/max settings #2052

Closed
ynamite opened this issue Jul 26, 2024 · 1 comment
Closed

AdaptiveDpr min/max settings #2052

ynamite opened this issue Jul 26, 2024 · 1 comment
Labels
question Further information is requested

Comments

@ynamite
Copy link

ynamite commented Jul 26, 2024

What is your question:

I'm a little confused about AdaptiveDpr and how it works. In the documentation (https://github.com/pmndrs/drei?tab=readme-ov-file#adaptivedpr) it says that AdaptiveDpr sets the DPR of the Canvas based on the Canvas performance min/max settings.
Drop this component into your scene and it will cut the pixel-ratio on regress according to the canvas's performance min/max settings.

Is this actually how it works? I checked out the source of AdaptiveDpr and it doesn't seem as if min/max settings are regarded at all.

I'm using the following Canvas code and regardless of the min/max settings I enter, the calculated DPR stays the same. Do I have to somehow set the initial DPR? And if so, how?

<Canvas
    gl={{
        antialias: false,
        stencil: false,
        powerPreference: 'high-performance',
        outputColorSpace: 'srgb',
    }}
    performance={{ min: 0.1, max: 0.5 }}
>
    <AdaptiveDpr pixelated />
</Canvas>

Thanks!

@ynamite ynamite added the question Further information is requested label Jul 26, 2024
@ynamite
Copy link
Author

ynamite commented Oct 4, 2024

I understand it now.

For anyone else struggling with this, you set the min/max DPR with the canvas prop dpr={[0.5,2]), for a min DPR of 0.5 and max of 2, for example. This means that if your device can handle it, the DPR will be a maximum of 2 and a minimum of 0.5. This DPR setting doesn't change on its own.

The value of performance.current is calculated based on a devices current performance to a range value between 0.0 and 1.0 . This value is then clamped to the min/max values of the performance prop. The current performance is multiplied with the DPR value from above. So when performance is 1.0 and the DPR is 2, the resolved DPR is 2. If performance drops to 0.5, the resolved DPR will be 1 and so on.

@ynamite ynamite closed this as completed Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant