Need to draw a line in one-pixel-width when antialiasing is on. (WebGL on chrome)

714 views
Skip to first unread message

Taekyu Shin

unread,
Apr 5, 2016, 10:55:48 AM4/5/16
to WebGL Dev List
Hi!

I have been working on some functionality in software.
May I please ask something that I see I could not figure out? It will be appreciated. :-)

My goal is to render a straight (completely vertical/horizontal at right angles) line CRISPY with AA on. (using antialias CSS style for OpenGL context --> canvas.getContext("experimental-webgl", { antialias: true });

Code is at below link. See the vertex shader part where that is happening.
(glMatrix-0.9.5.min.js is in the same folder WebGL-Playground.)


In order to do that, I have a WebGL sample with a special vertex shader. The vertex shader codes move the vertex position in NDC space so all vertex position (gl_Position) will be at the center of each pixel.
(For example, suppose that gl_FragCoord is going to be (300.1, 298.2) after running Vertex Shader. Then I nudge the vertex gl_Position in vertex shader, so in fragment shader, the gl_FragCoord will be (300.5, 298.5) (The center of the pixel according to DX11 rasterization spec. )

The goal is to render a line crispy (one-pixel width) in spite of MSAA anti-aliasing going on (either by browser or intel driver.)
(When I call getContext(), I pass "antialias: true" CSS style.  Even though anti-aliasing is on, because all samples for fragment shaders are at the center of each pixel, it should be drawn one pixel-width line, assuming MSAA sample area size is within one pixel.)

Here is my issue:

After rendering, ONLY FOR INTEL GPUs, the line is still drawn 3 pixel-width.

Please see the screenshot I attached below.

When I render a line with NVidia Quadro K600 , CLICK HERE.

When I render a line with Intel HD Graphics 5500, Intel HD Graphics 4600, CLICK HERE.

Does anybody have an explanation for this? Why does Intel GPU draw a line for 3 pixel width?  I imagine one of these: Either that ANGLE is doing something different for Intel GPU or that Intel driver AA sampling area is really wide.)
It seems not to be a driver bug since I tested on multiple GPUs with updated drivers. Multiple Intel GPUs had the same problem.)

I would really appreciate it! Have a great week, everybody! :-)

Taekyu Shin

unread,
Apr 5, 2016, 11:39:54 AM4/5/16
to WebGL Dev List
I used GL_LINES btw. :-)
Reply all
Reply to author
Forward
0 new messages