-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Texture3d support #14530
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
Texture3d support #14530
Conversation
|
|
Nice work. Can you make and add an 3D texture example under |
|
Probably. I don't have time right now to do this. I will try during a weekend. |
|
Adding a new doc page would also be great. BTW: What would happen if the user uses |
|
I'm thinking how |
| if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA; | ||
| if ( p === DepthFormat ) return gl.DEPTH_COMPONENT; | ||
| if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL; | ||
| if ( p === RedFormat ) return gl.RED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gl.RED is available only in WebGL2 so I think we need to check if gl is WebGL2RenderingContext.
if ( capabilities.isWebGL2 && p === RedFormat ) return gl.RED;
| import { Texture } from '../../textures/Texture.js'; | ||
|
|
||
| var emptyTexture = new Texture(); | ||
| var emptyTexture3d = new Texture(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't here new Texture3D()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably 👍
|
|
||
| Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); | ||
|
|
||
| this.image = { data: data, width: width, height: height, length: length }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reasons why you're targeting only data texture, not image texture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very simple reason - i only need a data texture. On the other hand - writing support for 3d images dataformat is a separate task from my point of view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Then I think module name DataTexture3D would sound more natural than Texture3D in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be a significant difference between a DataTexture3D and just a Texture3D in this case? The width, height, and depth need to be separately specified even if using an image to bind data:
https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/texImage3D
As a little bit of an aside, how is the data interpreted when binding a 2d image as a texture 3d?
|
I am still not convinced about the automatic deduction of the internal format. In my case for instance, I use particular texture with internal format, such as RG8UI. Maybe we could find a good way to add this internal format somewhere. What do you think? @takahirox |
|
|
||
| Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); | ||
|
|
||
| this.image = { data: data, width: width, height: height, length: length }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not depth make more sense than length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw Unity calls this dimension depth on their Texture3D
|
|
||
| if ( ! _gl.isWebGL2 ) return glFormat; | ||
|
|
||
| if ( glFormat === _gl.RED ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I need a RG16F?
|
This is awesome! Are there common standardized formats for 3d textures? |
|
Can you add an example under |
|
I locally made some examples
and confirmed this PR seems working. @artur-trzesiok seems to have been busy. So I wanna suggest to merge this PR so far. And we do renaming, adding an example, writing documents, brushing up, and so on in other PRs. |
|
Currently no 3D texture( This leads to a question to me. (I'm studying but still new to 3D texture.) Are there any other use cases and/or do we need to have material which can handle 3D texture? |
Sounds good! |
|
Thanks! |
|
|
||
| }() ); | ||
|
|
||
| this.setTexture3D = ( function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@takahirox we can probably remove this as this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You meant we can simply write as the following? If yes, I think so.
this.setTexture3D = function ( texture, slot ) {
textures.setTexture3D( texture, slot );
};
|
FWIW I also made a volume rendering example, which I proposed as a PR against @artur-trzesiok 's branch: K3D-tools#1 |
|
Cool. Do you also want to make PR to Three.js? |
|
Sure, I can do that. |
|
Wondering if we can have two 3D Texture examples. One is @almarklein 's example. Users can see how nice 3D Texture + Volume rendering is. And users could reuse volume rendering shaders. Another one is based on my simple and light example https://twitter.com/superhoge/status/1034875111923482625 Users can know how to use 3D Texture in Three.js. Sounds good? |
|
Sounds good! |


Working example from K3D-jupyter: