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

add 3D textures #20597

Merged
merged 1 commit into from
Aug 6, 2018
Merged

add 3D textures #20597

merged 1 commit into from
Aug 6, 2018

Conversation

karroffel
Copy link
Contributor

This PR adds new texture types, TEXTURE_TYPE_2D_ARRAY and TEXTURE_TYPE_3D.

The VisualServer API is changed slightly to compensate for the new dimensions needed. (@reduz said on IRC that this is acceptable since the servers are rarely used in games and are mostly for internal use)

The new types sampler3D, isampler3D, usampler3D as well as sampler2DArray, isampler2DArray and usampler2DArray have been added to the shader language, accompanied by the appropriate accessor functions.

A "highlevel" resource type, Texture3D has been added that can be used in-editor as a shader parameter by splitting an image into many layers. Via code the Texture3D can be filled with arbitrary data from differing formats.

Later on I will add a Texture2DArray highlevel resource type for completion.

@Zylann
Copy link
Contributor

Zylann commented Jul 30, 2018

Great stuff!
I am curious how users (or plugins) will be able to create such textures without needlessly importing 2D textures

@karroffel
Copy link
Contributor Author

@Zylann the Texture3D type accepts Ref<Image> for the data, I am using that for the property as well.

That's how the editor-interface looks like:

Juan pushed a commit a day ago to import image files as Image and not as Texture, so they don't reside in VRAM. This PR makes use of that.

So any texture you set as the "backend" doesn't have to be uploaded to GPU, so that should help a lot. (If I understood your concerns correctly)

@Two-Tone
Copy link

This could be useful in the medical industry. Stuff like fMRI scans are stored as just a bunch of textures (at least mine were).

@karroffel
Copy link
Contributor Author

@Two-Tone always a step ahead of you :)

https://gfycat.com/FluidNeatAfghanhound

@Two-Tone
Copy link

Two-Tone commented Jul 30, 2018 via email

@karroffel
Copy link
Contributor Author

@Two-Tone that's a problem with the shader I had, now I have a better shader that does perspective correction, that was just a Proof-of-concept, don't worry, the 3D texture works fine and has no wobbling :D

@Two-Tone
Copy link

Two-Tone commented Jul 30, 2018 via email

case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY:
case ShaderLanguage::TYPE_SAMPLER2DARRAY: {
// TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this is completed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah as I said, I want to add a Texture2DArray resource later on, just wanted to get this out and it already works if you use the low-level RIDs, but I'll definitely complete thsi! 👍

@@ -1876,3 +1876,209 @@ AnimatedTexture::AnimatedTexture() {
AnimatedTexture::~AnimatedTexture() {
VS::get_singleton()->free(proxy);
}

bool Texture3D::get_split_single_image_enabled() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you don't do this. A proper importer should be done, instead. Just make texture3D export/load an array of images (so they can be properly compressed if needed). I can handle the importer later if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I don't know how to deal with importers, so that would be great!

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

Successfully merging this pull request may close these issues.

4 participants