A couple of questions about being able to support point sprites in
ANGLE. Looking back at the writeup on D3D / OpenGL caveats from the
recent Khronos F2F, there is a statement that because of differences
in interpolation semantics between D3D and OpenGL, either point
sprites need to be implemented as a pair of triangles in ANGLE, or the
point size needs to be limited to 1.
The point sprite documentation in Direct3D 9 (
http://msdn.microsoft.com/en-us/library/bb147281(v=VS.85).aspx )
indicates that if D3DRS_POINTSPRITEENABLE is set to true, then the
values that come in to the fragment shader via TEXCOORD[n] will be
interpolated between (0,0) and (1,1). However, it states that the
vertex color attributes are constant across the sprite.
It seems to me that it should be possible to implement point sprites
with size > 1, support gl_PointSize and gl_PointCoord, and support the
transfer of the user's varying variables between the vertex and
fragment programs (though these will of course be constant across the
surface of the sprite). In the GLSL to HLSL translation, simply
transfer the user's varyings (and, basically, everything except
gl_PointCoord) in the COLOR[n] units. Enable D3DRS_POINTSPRITEENABLE
and synthesize gl_PointCoord from TEXCOORD[0]. A write to gl_PointSize
is translated to a write to PSIZE.
Will this work? I'd like to figure out whether WebGL authors can
reasonably expect point sprites with size > 1 to work without doing
expensive hacks behind the scenes like translating point sprites to
quads ourselves.
Thanks,
-Ken
^ +y| (0,0) | +-----+ | | | | | P | | | | | +-----+ | (1,1) | +x O--------------->
Open GL 2.0 w/ LOWER_LEFT
(based on §3.4.1 of the GL 3.3 core spec)
^ +y| (1,1)
| +-----+ | | | | | P | | | | | +-----+ | (0,0) | +x O--------------->
O--------------->
| | (0,0)
| +-----+ | | | | | P | | | | | +-----+ +y| (1,1)
ANGLE needs to convert the entire GLSL shader to HLSL anyway. During
this process it seems to me that it should be possible to synthesize
the value for gl_PointCoord as float2(texCoord0.x, 1.0 - texCoord0.y).
Wouldn't this solve the problem and allow D3D's built-in point sprites
to be used?
> Can WebGL authors can rely on having point sprites with size > 1? I would
> say that they cannot, regardless of what ANGLE implements. Technically, a
> maximum point size of 1 is all that is mandated by the ES 2.0 specification
> (see Section 3.3, and Table 6.17), thus that is all that WebGL can actually
> rely on being available by any ES implementation (or Desktop GL for that
> matter).
Understood, but a high quality implementation will allow the use of
larger point sprites if the hardware supports it. Authors should query
the ALIASED_POINT_SIZE_RANGE.
> Our plan for ANGLE is to initially support a maximum point size of 1.0 (and
> this is already completed already). At a later point this can be extended
> to draw quads if larger points are desired.
See above regarding question of whether it is necessary to draw quads
in order to emulate larger point sprites. I don't think it is.
-Ken