Skip to content

Commit

Permalink
Added docs for supported HDR formats (#6351)
Browse files Browse the repository at this point in the history
* Added docs for supported HDR formats

* update

* update

* indent

* Apply suggestions from code review

Co-authored-by: Will Eastcott <will@playcanvas.com>

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
  • Loading branch information
3 people authored May 13, 2024
1 parent d39421f commit 14b8fc6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
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

0 comments on commit 14b8fc6

Please sign in to comment.