News for hackers. Stuff that matters.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by pyalot2 on Monday September 16, 2013 @03:40AM (#6392071)
Ah my eyes, the aliasing.

If anybody's interested why there's aliasing it's important to know how CSS transforms work. If you transform, the browser lifts the transformed rectangle into its own layer and renders its content to a texture. Then, later, it is composited with the page by blitting that texture with whatever transformation was applied.

So CSS transforms are an application of texturing. And in texturing what you do to avoid aliasing is mipmapping (you might also throw anisotropic filtering on top). However as the texture holding the rect the browser rendered isn't square power of two, some devices do not support mipmapping it. It is also quite slow to generate the mipmap for a texture every frame.

So with CSS transforms not being able to utilize mipmapping --> aliasing.

Now, in particular mipmapping text (that's supposed to be sharp) isn't even the best idea. It just gets blurry and looks unappealing (although that's better with anisotropic filtering, but then, anisotropic filtering is also expensive and not every device/GPU supports it).

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by lookingsideways on Monday September 16, 2013 @05:09AM (#6392306)
Are you able to upload a screenshot of the aliasing problem somewhere?

Running on a retina MBP, both Safari and Chrome render the text pin-sharp with no noticeable aliasing.

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by kaoD on Monday September 16, 2013 @06:38AM (#6392523)
http://i.imgur.com/UzZYLW5.png

Check the farthest text. It's even worse in motion because the aliasing changes discretely.

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by chiph on Monday September 16, 2013 @11:39AM (#6393772)
Speaking as an old guy who saw Star Wars in the theater, it looked like that in 1977 as well. Not because of aliasing problems, but because they hit the resolution of the 35mm film and transfer process.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by ggchappell on Tuesday September 17, 2013 @02:35AM (#6397924)
Yup. OTOH, the errors didn't change discretely as the text moved.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by leokun on Monday September 16, 2013 @07:16AM (#6392645)
It looks fine on a Retina MBP. The farthest text gets a little tiny bit of flickering maybe, but it looks sharp all the way until it fades out. Nothing like that.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by ygra on Monday September 16, 2013 @07:29AM (#6392697)
The flickering is what kaoD referred to with discretely changing aliasing. It shouldn't happen, ideally. Small pixels make it a little less jarring but still noticeable.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by Pxtl on Monday September 16, 2013 @10:11AM (#6393323)
Heh, it still feels wonderfully retro, but instead of evoking the original Star Wars, it evokes the old early-'90s PC games like X-Wing.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by TimPietrusky on Monday September 16, 2013 @03:46AM (#6392089)
So what do you suggest I should change?

Thanks in advance.

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by pyalot2 on Monday September 16, 2013 @04:29AM (#6392195)
Well in CSS you can't do anything about it, that's just how the browser works.

If you'd be doing WebGL you can do some things like using square power of two textures and enabling mipmapping and if available anisotropic filtering.

You can also do things like using signed distance field fonts or draw fonts by rasterizing (in the fragment shader) the bezier curves, which can be made to nicely anti-alias (using standard derivatives).

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by ghayes on Monday September 16, 2013 @04:37AM (#6392220)
Is this to say that CSS 3D transformations on text are bound to be aliased [in similar circumstances]? Is there a suggestion to the spec such as a "mipmap hint" that could (one day) be added to reduce this flaw without the need for other technologies?
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by pyalot2 on Monday September 16, 2013 @05:30AM (#6392362)
It's not just 3D transforms, a simple scale down will exhibit aliasing as well.

There's no flag to control aliasing migitating strategies for CSS in the spec, nor is there any discussion about it as far as I know.

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by capisce on Monday September 16, 2013 @06:33AM (#6392512)
We call this a leaky abstraction :)
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by derefr on Monday September 16, 2013 @11:45AM (#6393813)
> draw fonts by rasterizing (in the fragment shader) the bezier curves

So, ideally, browsers would be doing this themselves, after applying the transform to any non-text in the texture, and then compositing with the combined texture?

Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by gnoway on Monday September 16, 2013 @07:26AM (#6392685)
Could be the speed, content, or something else, but the text at http://fotcorn.github.io/StarRSS/ doesn't seem to shake (as much, anyway) as it fades.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by ygra on Monday September 16, 2013 @07:31AM (#6392701)
Exhibits exactly the same issue here. Horrible flickering of horizontal lines because those alternate between being a pixel and no pixel wide.
Re:Star Wars opening crawl from 1977 in HTML/CSS/JS by jcampbell1 on Monday September 16, 2013 @12:15PM (#6393977)
You could make everything oversized, then apply a scale of .25. That will improve the aliasing a bit.

Same for the logo. The scale transform should never exceed 1.0.