Skip to content

WebGPURenderer: FloatType StorageTextures cannot be used on mobile devices with no filterable support #33147

@gkjohnson

Description

@gkjohnson

Description

When using a storage texture that is marked as "FloatType" it seems to not be possible to use it at all for rendering on devices that do not support float32-filterable even when the texture settings are set to NearestFilter. This happens when simply assigning the texture to a material "map" or even when using the texture with "textureLoad" which requires no sampler at all, which is what I have been trying to use:

const storageTex = new StorageTexture( 1, 1 );
storageTex.type = FloatType;
storageTex.minFilter = NearestFilter;
storageTex.magFilter = NearestFilter;

wgslFn( /* wgsl */`
fn sampleTexel( tex: texture_2d<f32>, coord: vec2f ) -> vec4f {

	// Manual bilinear filtering using textureLoad to support filterable float32 textures
	// on all devices
	let size = vec2f( textureDimensions( tex, 0 ) );
	let pxCoord = coord * size - 0.5;
	let px = vec2i( floor( pxCoord ) );

	// get the four sibling samples
	return textureLoad( tex, px, 0 );

}`, {
  tex: texture( storageTex ).setSampler( false ),
  coord: varing( uv() ),
} );

This is again something I ran into while working on the path tracer and trying to get it working on mobile. Ideally using something like "setSampler( false )" would be enough to guarantee this to work in addition to respecting the system flags and checking the filter settings.

Reproduction steps

  1. Create a float-type storage texture
  2. Hook it up to use texture sampling or textureLoad with no filtering set on the texture
  3. Render on a device with no float32-filterable support
  4. See failure

Code

const storageTexture = new THREE.StorageTexture( 1, 1 );
storageTexture.type = THREE.FloatType;
storageTexture.minFilter = THREE.NearestFilter;
storageTexture.magFilter = THREE.NearestFilter;

const material = new MeshBasicMaterial( { map: storageTexture } );

Live example

https://jsfiddle.net/bo3nys2a/

Screenshots

Image

Version

r183

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTSLThree.js Shading Language

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions