Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using native WebGLTexture as a RawShaderMaterial uniform #5230

Closed
Siroko opened this issue Aug 23, 2014 · 8 comments
Closed

Using native WebGLTexture as a RawShaderMaterial uniform #5230

Siroko opened this issue Aug 23, 2014 · 8 comments

Comments

@Siroko
Copy link

Siroko commented Aug 23, 2014

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!

@Siroko
Copy link
Author

Siroko commented Aug 23, 2014

Ops, I just found a way :

var texture = new THREE.Texture();
texture.__webglInit = true;
texture.__webglTexture = myWebGLNativeTexture;

Is there anything wrong with this workaround?

@mrdoob
Copy link
Owner

mrdoob commented Aug 24, 2014

Hmmm, what's wrong is that there isn't a better API for it :P
It's not a WebGLRenderTarget, is it?

@mrdoob
Copy link
Owner

mrdoob commented Aug 24, 2014

Maybe we can do some sort of THREE.WebGLTexture?

@Siroko
Copy link
Author

Siroko commented Aug 24, 2014

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 :)

@brianchirls
Copy link
Contributor

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.

@valentin-pinkau
Copy link

Is there any progress on this issue?
Would it be hard to overload the THREE.Texture constructor to use a WebGLTexture as an argument?

@schteppe
Copy link

This seems to work in r85:

var texture = new THREE.Texture();
var properties = renderer.properties.get( texture );
properties.__webglTexture = myWebGLNativeTexture;
properties.__webglInit = true;

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 18, 2021

Duplicate of #17766.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants