Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs for supported HDR formats #6351

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/platform/graphics/graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ class GraphicsDevice extends EventHandler {
*/
textureHalfFloatRenderable;

/**
* True if small-float textures with format {@link PIXELFORMAT_111110F} can be used as a frame
* buffer. This is always true on WebGL2, but optional on WebGPU device.
*
* @type {boolean}
* @readonly
*/
textureRG11B10Renderable = false;

/**
* True if filtering can be applied when sampling float textures.
*
Expand Down Expand Up @@ -855,6 +864,12 @@ class GraphicsDevice extends EventHandler {
/**
* Get a renderable HDR pixel format supported by the graphics device.
*
* Note:
* - When the `filterable` parameter is set to false, this function returns one of the supported
* formats on the majority of devices apart from some very old iOS and Android devices (99%).
* - When the `filterable` parameter is set to true, the function returns a format on a
* considerably lower number of devices (70%).
*
* @param {number[]} [formats] - An array of pixel formats to check for support. Can contain:
*
* - {@link PIXELFORMAT_111110F}
Expand Down
21 changes: 21 additions & 0 deletions src/platform/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ let id = 0;
* A texture is a container for texel data that can be utilized in a fragment shader. Typically,
* the texel data represents an image that is mapped over geometry.
*
* Note on **HDR texture format** support:
* 1. **As textures**:
* - float (i.e. {@link PIXELFORMAT_RGBA32F}), half-float (i.e. {@link PIXELFORMAT_RGBA16F}) and
* small-float ({@link PIXELFORMAT_111110F}) formats are always supported on both WebGL2 and WebGPU
* with point sampling.
* - half-float and small-float formats are always supported on WebGL2 and WebGPU with linear
* sampling.
* - float formats are supported on WebGL2 and WebGPU with linear sampling only if
* {@link GraphicsDevice#textureFloatFilterable} is true.
*
* 2. **As renderable textures** that can be used as color buffers in a {@link RenderTarget}:
* - on WebGPU, rendering to float and half-float formats is always supported.
* - on WebGPU, rendering to small-float format is supported only if
* {@link GraphicsDevice#textureRG11B10Renderable} is true.
* - on WebGL2, rendering to these 3 formats formats is supported only if
* {@link GraphicsDevice#textureFloatRenderable} is true.
* - on WebGL2, if {@link GraphicsDevice#textureFloatRenderable} is false, but
* {@link GraphicsDevice#textureHalfFloatRenderable} is true, rendering to half-float formats only
* is supported. This is the case of many mobile iOS devices.
* - you can determine available renderable HDR format using
* {@link GraphicsDevice#getRenderableHdrFormat}.
* @category Graphics
*/
class Texture {
Expand Down