THREE.UnsignedShortType
See original GitHub issueHi,
I’m making a terrain renderer, and I’m using 16bit grayscale pngs as displacement maps. When I load them using THREE.ImageUtils.loadTexture, it works, but I get noticable rounding errors. So I tried to modifiy it like this:
function loadDEM(path, mapping, callback) {
var image = new Image(), texture = new THREE.Texture(image, mapping);
texture.type = THREE.UnsignedShortType;
image.onload = function() {
texture.needsUpdate = true;
if (callback) {
callback(this);
}
}
image.crossOrigin = "anonymous";
image.src = path;
return texture;
}
Just added texture.type = THREE.UnsignedShortType, and now I get these errors in console and terrain is flat.
WebGL: INVALID_ENUM: texImage2D: invalid texture type index.html:1
WebGL: INVALID_OPERATION: generateMipmap: level 0 not power of 2 or not all the same size
So how can I use 16bit images?
This is the actual terrain tile:

Issue Analytics
- State:
- Created 11 years ago
- Comments:20 (5 by maintainers)
Top Results From Across the Web
Texture Constants
The last pixel of the texture stretches to the edge of the mesh. With MirroredRepeatWrapping the texture will repeats to infinity, mirroring on...
Read more >three UnsignedShortType JavaScript Examples
This page shows JavaScript code examples of three UnsignedShortType. ... depthTexture = new DepthTexture(); depthTexture.type = UnsignedShortType; this.
Read more >DataTexture with LuminanceFormat UnsignedShort is not ...
I have some OpenGL code I want to bring to WebGL / three.js: glTexImage2D(GL_TEXTURE_2D, 0 ... UnsignedShortType); var material = new THREE.
Read more >DataTexture
Other valid types (as WebGL allows) are THREE. ... UnsignedShortType, THREE. ... CubeReflectionMapping, for cube maps used as a reflection map; THREE.
Read more >examples/webgl_depth_texture.html - three.js
DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <title>three.js webgl - Depth ... DepthStencilFormat }; 98 const types = { UnsignedShortType: THREE.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Like all image formats in browsers it’s up to the browser what image formats are supported and what the browser does with them. 😭 For example Chrome and Firefox support webp but Safari does not.
Also Safari supports (or used to support) TIFF files as
<img>tags and it would load and display floating point TIFFs but I’m 99% it did not support uploading those floating point TIFFs as floating point textures as there is no conformance test for it (not that Apple has ever cared about passing the conformance tests 😂)Currently though the WebGL2 spec explicitly disallows 16 int formats from images 🙄
@greggman Thank your for clarifying! In this case, the issue can safely be closed.