Skip to content

Conversation

@artur-trzesiok
Copy link
Contributor

@artur-trzesiok artur-trzesiok commented Jul 23, 2018

@moraxy
Copy link
Contributor

moraxy commented Jul 23, 2018

nevermind :sweat_smile: 

@takahirox
Copy link
Collaborator

takahirox commented Jul 23, 2018

Nice work. Can you make and add an 3D texture example under examples/?

@artur-trzesiok
Copy link
Contributor Author

Probably. I don't have time right now to do this. I will try during a weekend.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 25, 2018

Adding a new doc page would also be great. BTW: What would happen if the user uses Texture3D with a WebGL 1 context? It's maybe a good idea to detect this and provide an informative warning.

@takahirox
Copy link
Collaborator

I'm thinking how TextureLoader supports 3D texture. I'm not familiar with 3D texture yet. Can we detect if image is for 3D texture from the filename extension or something?

@mrdoob mrdoob added this to the r96 milestone Jul 25, 2018
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;
Copy link
Collaborator

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();
Copy link
Collaborator

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()?

Copy link
Owner

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 };
Copy link
Collaborator

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?

Copy link
Contributor Author

@artur-trzesiok artur-trzesiok Jul 31, 2018

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.

Copy link
Collaborator

@takahirox takahirox Jul 31, 2018

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.

Copy link
Collaborator

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?

@DavidPeicho
Copy link
Contributor

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

@artur-trzesiok
Copy link
Contributor Author

New examples:
k3d-1532603480276
k3d-1532603595150


Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );

this.image = { data: data, width: width, height: height, length: length };
Copy link
Contributor

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?

Copy link
Collaborator

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 ) {
Copy link
Contributor

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?

@gkjohnson
Copy link
Collaborator

This is awesome! Are there common standardized formats for 3d textures?

@takahirox
Copy link
Collaborator

takahirox commented Aug 6, 2018

Can you add an example under examples/? https://github.com/mrdoob/three.js/tree/dev/examples in this PR? Users and developers can see 3D texture works on Three.js.

@mrdoob mrdoob modified the milestones: r96, r97 Aug 29, 2018
@takahirox
Copy link
Collaborator

takahirox commented Aug 31, 2018

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.

@takahirox
Copy link
Collaborator

takahirox commented Aug 31, 2018

Currently no 3D texture(sampler3D and texture( sampler3D, vec3 )) in default shaders. So users must use [Raw]ShaderMaterial for 3D texture. I think it's good start. I heard major use cases of 3D texture are Volume rendering and sometimes gpgpu. In general users write their shader codes for them.

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?

@mrdoob
Copy link
Owner

mrdoob commented Aug 31, 2018

@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.

Sounds good!

@mrdoob mrdoob merged commit 118ef7c into mrdoob:dev Aug 31, 2018
@mrdoob
Copy link
Owner

mrdoob commented Aug 31, 2018

Thanks!


}() );

this.setTexture3D = ( function () {
Copy link
Owner

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?

Copy link
Collaborator

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

};

@almarklein
Copy link
Contributor

FWIW I also made a volume rendering example, which I proposed as a PR against @artur-trzesiok 's branch: K3D-tools#1

@takahirox
Copy link
Collaborator

Cool. Do you also want to make PR to Three.js?

@almarklein
Copy link
Contributor

Sure, I can do that.

@takahirox
Copy link
Collaborator

takahirox commented Sep 4, 2018

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?

@mrdoob
Copy link
Owner

mrdoob commented Sep 4, 2018

Sounds good!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants