0
我有一個關於GL_LUMINANCE與uint16數據的小問題。我有一些OpenGL的代碼,我想帶給WebGL的/ three.js所:DataTexture與LuminanceFormat UnsignedShort無法渲染
glTexImage2D(GL_TEXTURE_2D, 0, myColor, (ushort)width,
(ushort)height, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, imageData);
當運行這個基本示例代碼我得到的錯誤
texture bound to texture unit 0 is not renderable.
It maybe non-power-of-2 and have incompatible texture filtering.
我不是專家,所以也許這並根本不工作? 所以,這就是基本的樣本:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<script type="text/javascript" src="js/three.js"></script>
</head>
<body>
<canvas id="c" width="800" height="800" style="border:1px solid">No canvas functionality</canvas>
<script>
var canvas = document.getElementById("c");
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, canvas.width/canvas.height, 0.1, 1000);
var renderer = new THREE.WebGLRenderer({ canvas: canvas });
var test = new Uint16Array(2048 * 2048);
for(var i = 0; i < test.length; i++) {
test[i] = Math.floor((Math.random() * 0xFFFF) + 1);
}
var geometry = new THREE.PlaneGeometry(1, 1);
var tex = new THREE.DataTexture(test, 2048, 2048, THREE.LuminanceFormat, THREE.UnsignedShortType);
var material = new THREE.MeshBasicMaterial({ map: tex });
var mesh = new THREE.Mesh(geometry, this.material);
material.map.needsUpdate = true;
scene.add(mesh);
var bbox = new THREE.BoundingBoxHelper(mesh, 0xFF0000);
bbox.update();
scene.add(bbox);
camera.position.z = 1;
function render() {
renderer.render(scene, camera);
}
requestAnimationFrame(render);
</script>
</body>
</html>
在此先感謝
不是一個答案,但你的榜樣使用'THREE.LuminanceFormat','Uint8Array'和'THREE.UnsignedByteType'。檢查WebGL規範的限制。 – WestLangley