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

How to make textures look sharp on a retina display? #2553

Closed
emilsjolander opened this issue Oct 24, 2012 · 16 comments
Closed

How to make textures look sharp on a retina display? #2553

emilsjolander opened this issue Oct 24, 2012 · 16 comments
Labels

Comments

@emilsjolander
Copy link

So i just updated my laptop to a retina display macbook and even though i use high resolution textures with repetition they look very blurry.

So i am wondering what i should do to resolve this issue?

@mrdoob
Copy link
Owner

mrdoob commented Oct 24, 2012

Anisotropy is probably what you're after.
http://mrdoob.github.com/three.js/examples/webgl_materials_texture_anisotropy.html

@emilsjolander
Copy link
Author

ok this fixed my issue with repeating textures, thx :) However it did not work for non repeating textures, any idea on how this can be fixed?

@mrdoob
Copy link
Owner

mrdoob commented Oct 24, 2012

They probably need to be power of two textures?

@emilsjolander
Copy link
Author

well i have tried increasing the resolution of the textures but i am not seeing an improvement. Without actually knowing how the increased density is handled, my guess is that the texture is being downscaled to the appropriate pixel size of the geometry face but is than scaled up again by my browser to fit the density of the display.

When looking closer at my repeating texture i can see that while setting the anisotropy to max greatly increased the quality, the texture is still not as sharp as it should be

@alteredq
Copy link
Contributor

Hard to tell what's going on without seeing the example or at least screenshots, but you may want to have a look at this:

http://www.khronos.org/webgl/wiki/HandlingHighDPI

@emilsjolander
Copy link
Author

awesome link @alteredq ! fixed my issues, everything looks sharp now :)

@igneosaur
Copy link

Just leaving a comment here for anyone else that finds this, because I almost went mad trying to find an answer and Google kept bringing me here: I had the exact same problem but mine was a very simple solution, it was to simply set the devicePixelRatio in the renderer (r72):

renderer.setPixelRatio(window.devicePixelRatio ? window.devicePixelRatio : 1);

Worth noting that setting the devicePixelRatio at object creation does not work. Maybe a bug?

@mrdoob
Copy link
Owner

mrdoob commented Oct 9, 2015

Worth noting that setting the devicePixelRatio at object creation does not work. Maybe a bug?

That got removed a while ago.

@mietek
Copy link

mietek commented Dec 24, 2015

@mrdoob, @greggman: FYI, it is not at all clear that one has to call renderer.setPixelRatio before calling renderer.setSize.

@mrdoob
Copy link
Owner

mrdoob commented Dec 25, 2015

@mietek Actually, I think this may have been fixed in dev unintentionally already...

@makc
Copy link
Contributor

makc commented Jan 24, 2016

it is not at all clear that one has to call renderer.setPixelRatio before calling renderer.setSize.

it is not even helping, or so it seems. this is what I get in safari console:

screen shot 2016-01-24 at 19 15 50

and this is how it looks like in ipad:

screen shot 2016-01-24 at 19 21 05

as you see, the rectangle appears to be of right size, but the actual viewport is 2x larger.

@makc
Copy link
Contributor

makc commented Jan 24, 2016

things look right in chrome's simulator with dpr=2 but on ipad they do not.

@mrdoob
Copy link
Owner

mrdoob commented Jan 24, 2016

@makc do you have a link?

@makc
Copy link
Contributor

makc commented Jan 24, 2016

[removed]

@mrdoob
Copy link
Owner

mrdoob commented Jan 24, 2016

Something else is going on...

screen shot 2016-01-24 at 19 12 49

Using Safari's Developer Tools, I have changed style="width: 418px to style="width: 408px and back and it looks as it should. I bet there is some other css rule messing things.

@makc
Copy link
Contributor

makc commented Jan 24, 2016

it appears that tilting the thing back and forth fixes this as well... any way, this

        setTimeout (function () {
            renderer.domElement.style.width = (parseInt (renderer.domElement.style.width) - 1) + 'px';
            setTimeout (function () {
                renderer.domElement.style.width = (parseInt (renderer.domElement.style.width) + 1) + 'px';
            }, 0);
        }, 0);

did not work at all. back to drawing board...

psastras pushed a commit to psastras/vizceral that referenced this issue Nov 1, 2016
    - fixes blurry texture rendering on retina like displays
      (see: mrdoob/three.js#2553)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants