[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] How to set a canvas backing store to display units?

On Fri, Jun 15, 2012 at 8:42 PM, James Darpinian <jdarpinian@google.com> wrote:
On Fri, Jun 15, 2012 at 8:57 AM, Ian Hickson <ian@hixie.ch> wrote:
I agree this would be desirable; however it is impossible to implement. In WebGL the rendering coordinate space and the backing store size are not independent and that can't be fixed (efficiently) without changes to OpenGL/DirectX.
Reason for that is twofold:
1) gl_FragCoord is in backing store size, even if you shmied translation over every API call dealing with viewport dimensions you'd still have shader code that doesn't work. However, you could, hypothethically add some hack to translate that inside the shader, but that won't work because:
2) If gl_FragCoord.xy +- 1 is not pointing to the next fragments coords, any post-processing effect will "jump pixels", and produce unusable output.
Furthermore, the kind of content WebGL is used for usually doesn't need to be rendered at full display resolution to look acceptable. Pixel-doubling the sharp vectors and text commonly rendered in a 2D context looks terrible, but pixel-doubling the more natural 3D scenes WebGL excels at looks fine. In fact, most console games render at less than full display resolution because performance is more important.
Actually console games do render at "full resolution" if you define 720p as "full". But there are games that render at 1080p, admittedly not terribly many.