Do you have any clue for passing a native WebGLTexture to one Shader in a Three material?
We are sharing the Three gl context to do a series of calculations and stuff on the GPU, but the main purpose is to render the final data with three, so I need to put my output texture (WebGLTexture) as a Sampler2D uniform in a THREE.RawShaderMaterial. I don't know if this is possible using the available API of the engine.
Thanks in advance and keep up the great work!
Ops, I just found a way :
var texture = new THREE.Texture();
texture.__webglInit = true;
texture.__webglTexture = myWebGLNativeTexture;
Is there anything wrong with this workaround?
Hmmm, what's wrong is that there isn't a better API for it :P
It's not a WebGLRenderTarget, is it?
Maybe we can do some sort of THREE.WebGLTexture?
Yes, a THREE.WebGLTexture would be great, but is not as easy as I thought.. there are some issues when using this approach, while another Three geometry is at the viewport, the webglTexture seems like removed from the material :( I think this should be because the texture slot of the webGLTexture is static and the engine doesn't know nothing about it so probably is overriding it.
I still looking for a good approach to solve this and being able to use our GPU stuff within Three.js without issues :)
I'd like to put in a vote for a variety of Texture that uses a WebGLTexture as the source image. It would be much more flexible than passing it directly to a RawShaderMaterial because you'd still be able to use the Texture as a source for other kinds of material.
Is there any progress on this issue?
Would it be hard to overload the THREE.Texture constructor to use a WebGLTexture as an argument?
This seems to work in r85:
var texture = new THREE.Texture();
var properties = renderer.properties.get( texture );
properties.__webglTexture = myWebGLNativeTexture;
properties.__webglInit = true;
Most helpful comment
This seems to work in r85: