Skip to content

[TRACKER] iOS rendering bugs related to half_float precision issues #38441

Closed
@clayjohn

Description

Recently, while investigating a potential batching bug, @lawnjelly traced back rendering issues on an iOS device to the use of half float UVs. When an ArrayMesh is set to use compression, it will use half float (16 bit) formats instead of full float (32 bit). This cuts the size of the mesh in half, but can result in precision issues. The use of half floats is enabled by the extension GL_HALF_FLOAT_OES which is "available" on all GLES2 devices. I say "available" because iOS register the extension and present it as available, but silently fail when half floats are used in a vertex format. This comment #38318 (comment) presents a partial fix to the problem, but a more robust fix is needed.

I see two avenues to approach this problem:

  1. The issues are most obvious when rendering a mesh after having rendered certain GUI primitives. This seems to suggest that mixing half_floats and floats is a problem (e.g. the vertex buffer doesn't like switching between the two formats. This may require us to allocate more buffers to keep things clearly separated.

  2. The issue clearly stems from the use of GL_HALF_FLOAT_OES, so an obvious (but not necessarily optimal) fix would be to force iOS devices to never use half floats here:

    #ifdef JAVASCRIPT_ENABLED
    config.support_half_float_vertices = false;
    #else
    //every other platform, be it mobile or desktop, supports this (even if not in the GLES2 spec).
    config.support_half_float_vertices = true;
    #endif

config.support_half_float_vertices = true;
//every platform should support this except web, iOS has issues with their support, so disable
#ifdef JAVASCRIPT_ENABLED
	config.support_half_float_vertices = false;
#endif 
#ifdef IPHONE_ENABLED
	config.support_half_float_vertices = false;
#endif

This solution, while easy, would result in iOS devices never compressing vertex data, which will unnecessarily increase the amount of VRAM used.

The following issues appear to stem from this particular issue and will likely be solved by the fixes above:

The following issues may come from this particular issue and may be solved by the fixes above:

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions