create3000 / cobweb

Cobweb is now X_ITE
https://github.com/create3000/x_ite
Other
10 stars 5 forks source link

ideas for possible optimization #21

Closed andreasplesch closed 7 years ago

andreasplesch commented 7 years ago

An issue to collect random ideas for cobweb optimization.

1) In a scene with textures Mozilla's console shows this: Error: WebGL: texImage2D: Uploading ArrayBuffers with FLIP_Y or PREMULTIPLY_ALPHA is slow.

2) It looks like ImageTexture.js puts the image first in a new canvas element, then extracts it back out of the canvas to provide it as texture data for webgl. webgl allows for directly using the canvas element as texture source which should be faster ? Same for <video>.

create3000 commented 7 years ago

1) Why does the WebGL standard adds this handy feature if then a browser returns such an error. Could implement this feature in JavaScript, either by flipping the pixels or by modifying the texture matrix. Changes must be done also in Titania.

2) Nop. This isn't possible, because of the (expensive) alpha test to have at least a distinction beween RGB and RBA textures. For this test the pixel data are required and this is later the argument for X3DTexture2DNode.setTexture.

create3000 commented 7 years ago

2) If a dom element (image or video tag) is provided to gl.texImage2D then there is no border argument anymore, but this is required by TextureProperties.

andreasplesch commented 7 years ago

ok. Just some thoughts 1) perhaps chrome is fast for this. 2) I looked up gl.texImage2D

https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D

The border argument needs to 0. It is probably there only for opengl compatibility.

For DOM integration it could be nice to have a CanvasTexture node which accepts a canvas dom element as a dynamic texture source (perhaps with some limitations).