-
Notifications
You must be signed in to change notification settings - Fork 294
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
[USAGE TIP] Workaround for low perceived quality on devices with high DPI #46
Comments
Would it be possible to encapsulate this within |
Hello 🙋 I managed to solve the problem with performance picking 😀. The idea, as you @xeolabs suggest is to provide a new What I will try to do now is to implement it with a setter/getter, as this could then act as a dynamically adjustable "render quality" switch (although only for devices where I did some quick tests with its performance, and for example on an iPad with retina display where Just stay tuned, I will try to send a PR for this one at the end of this week 😀. |
Hi! I would like to know if this functionality that tmarti describes has been implemented into XeoKit. Or how to implement it if it is not. Could anyone point me in the right direction? |
Hey @david-San, I had this code prepared somewhere but within our private fork of xeokit, so I can't really share the code. BUT the idea was to propagate Things that I remember to take into account:
I think those were all important aspects to take into account to have nice sharp edges :) |
Just found a really easy solution to this problem, tested on Chrome, Firefox and Safari: <style>
body {
position: absolute;
margin: auto;
transform-origin: top left;
}
#xeokit_canvas {
width: 100%;
height: 100%;
}
</style>
<body id="the_body">
<canvas id="xeokit_canvas"></canvas>
</body>
<script>
the_body.style.transform = "scale(" + (1/window.devicePixelRatio) + ")";
the_body.style.width = (window.devicePixelRatio*100) + "%";
the_body.style.height = (window.devicePixelRatio*100) + "%";
</script> The point is that by default the viewport is downscaled according to DPI scaling ( So if for example that factor is 2.5, the viewport is downscaled by that number... then the trick is to upscale the body by that factor 😉 (adjusting We need a combination of CSS styling and JS code because the Enjoy! 😃 |
Hi tmarti! Thank you so much for sharing this. This is excellent! I tried it and it works. I can now get a very high resolution rather than the grainy effect. The only thing that I have not found a solution when implementing your code is that everything on the screen looks very small since text is following the window.devicePixelRatio change. Do you have any ideas how to overcome this problem? Changing the font size to huge seem like the evident solution but I am not sure if there is a more elegant solution. |
Maybe you could create a container div also with position absolute to that
it overlays with the canvas, and apply the inverse transform (i.e. a
downscale transform) to it?
Just guessing ;)
El dv., 6 des. 2019, 13:25, david-San <[email protected]> va
escriure:
… Hi tmarti! Thank you so much for sharing this.
This is excellent! I tried it and it works. I can now get a very high
resolution rather than the grainy effect.
The only thing that I have not found a solution when implementing your
code is that everything on the screen looks very small since text is
following the window.devicePixelRatio change.
Do you have any ideas how to overcome this problem? Changing the font size
to huge seem like the evident solution but I am not sure if there is a more
elegant solution.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#46?email_source=notifications&email_token=AASLIJSL5NA565ZXWN5WRV3QXJAEZA5CNFSM4HEJZL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGD52SY#issuecomment-562552139>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASLIJUKFPLPESJZCWHODJLQXJAEZANCNFSM4HEJZL6A>
.
|
Is there a more recent solution ? |
I just found this : |
The reason I didn't even bother trying out xeokit was that it just looked so blurry on my M3. Would be nice if this would be fixed by default (in the examples?) |
Hi, do you mean blurry after applying the workaround mentioned above? Could you provide a code sample of how you've set up the Viewer / HTML / CSS? PRs always welcome of course. |
I've got this issue on xeo.vision and on any hosted example. The screenshots are from https://xeokit.io/demo.html?projectId=MAP Default look (in miniature this looks fine, but its just a bit blurry / unsharp if I'm using this full screen to replace ifc.js): Zooming out in the browser window seems to resolve the issue: I'll try setting the resolution scale myself, but as I said this discouraged me from using it at all initially (and probably not only me, because everyone looks at the visuals in the first). |
Hi @NiklasPor, Thank you for the report and detailed investigation into the issue. We have just implemented a change to how the What this change does not do however, is it doesn’t change the default value of The change will be included in an upcoming release, looking forward to your feedback. |
On devices where
window.devicePixelRatio
returns a value greater than 1 , there is a visual reduction of perceived quality on the 3d rendering.This happens on most mobile devices (pads and phones), where the canvas size as calculated by the
viewer/scene/canvas/Canvas.js
class can have a much lower pixel count than what's the phyisical pixel count of the canvas, due to DPI scaling by the browser.One simple solution seems to be allowing to externally provide the desired
devicePixelRatio
(ideally taken fromwindow.devicePixelRatio
) when creating the instance of theViewer
class and propagate it all the way down to theCanvas
class (falling back to 1, for example) so that it can take into account that "scaling factor" when setting the canvas width/height and the viewport bounds.I've did a quick test and that seems to have the effect of now having nice sharp edges on the mobile viewer (both tablet and phone), although I still have some issues with it (e.g. performance picking seems to suffer a clipping efffect (it only works within a region of the viewer canvas)).
If you want, I can create a PR with those changes (propagating the
devicePixelRatio
down to theCanvas
) so that we can collaborate further in solving this 😃The text was updated successfully, but these errors were encountered: