pointSize 大于 1 的顶点的屏幕坐标
screen coordinates of a vertex with pointSize bigger than 1
假设canvas大小为(wx,wy),则顶点左下角的精确坐标为(-1 + 1/wx , -1 + 1/wy)。
但是当pointSize大于1时,我找不到公式。
在此 fiddle、https://jsfiddle.net/3u26rpf0/14/ 中,我使用以下公式绘制了一些大小为 1 的像素 gl_Position:
float p1 = -1.0 + (2.0 * a_position.x + 1.0) / wx ;
float p2 = -1.0 + (2.0 * a_position.y + 1.0) / wy ;
gl_Position=vec4(p1,p2,0.0,1.0);
a_position.x 从 0 到 wx-1 .
a_position.y 从 0 到 wy-1 。
但如果您更改顶点中的大小值(参见 fiddle link)
我的公式不起作用,需要输入一些偏移量。
来自OpenGL ES 2.0 spec section 3.3
Point rasterization produces a fragment for each framebuffer pixel whose center
lies inside a square centered at the point’s (xw, yw), with side length equal to
the point size
假设canvas大小为(wx,wy),则顶点左下角的精确坐标为(-1 + 1/wx , -1 + 1/wy)。 但是当pointSize大于1时,我找不到公式。
在此 fiddle、https://jsfiddle.net/3u26rpf0/14/ 中,我使用以下公式绘制了一些大小为 1 的像素 gl_Position:
float p1 = -1.0 + (2.0 * a_position.x + 1.0) / wx ;
float p2 = -1.0 + (2.0 * a_position.y + 1.0) / wy ;
gl_Position=vec4(p1,p2,0.0,1.0);
a_position.x 从 0 到 wx-1 .
a_position.y 从 0 到 wy-1 。
但如果您更改顶点中的大小值(参见 fiddle link) 我的公式不起作用,需要输入一些偏移量。
来自OpenGL ES 2.0 spec section 3.3
Point rasterization produces a fragment for each framebuffer pixel whose center lies inside a square centered at the point’s (xw, yw), with side length equal to the point size