cesium icon indicating copy to clipboard operation
cesium copied to clipboard

PixelFormat.R undefined in WebGL2

Open Mofangbao opened this issue 6 years ago • 2 comments

PixelFormat.R is used in PixelFormat.toInternalFormat,but it's undefined. When use float texture in WebGL1,alpha channel with pixelDatatype.FLOAT works, But,When use float texture in WebGL2,we can't get correct float value with alpha channal and console outputs "GL_INVALID_OPERATION: Invalid internal format".

Thanks a lot.

Mofangbao avatar Nov 16 '20 00:11 Mofangbao

Here's a sandcastle example for testing this: Sandcastle

The two switch-case statements in PixelFormat.toInternalFormat are incorrectly using PixelFormat.R and PixelFormat.RG which don't exist, and should instead be checking PixelFormat.LUMINANCE, PixelFormat.ALPHA, and PixelFormat.LUMINANCE_ALPHA.

This is half the fix. The other half is in Texture and CubeMap which are using the correct internalFormat with the fix above but not the right pixelFormat. In WebGL2 the pixelFormat for floating point LUMINANCE_ALPHA, LUMINANCE, or ALPHA textures should be RG, RED, and RED respectively. Though I'm not sure if this is completely correct since it ignores the fact that luminance is really grayscale RGB and alpha is for the alpha channel not the red channel. May need more investigation.

See https://www.khronos.org/registry/webgl/specs/latest/2.0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE for a list of valid internal format, format, and type in WebGL 2.

lilleyse avatar Nov 30 '20 13:11 lilleyse

Thanks a lot.

Mofangbao avatar Dec 13 '21 02:12 Mofangbao