- Home /
3d textures possible? (cg sampler3D type)
Is it possible to create 3d textures in unity somehow? Or just import them as assets and use them in cg?
Looks like shaderLab accepts 3D type in it properties, so this '_VolumeTexture ("3d tex", 3D) = "white" {}' compiles and shows type as Volume in the inspector. I should be able to pass a 3d texture to my shader, but I still have the problem of creating it...
I tried to declare a property _VolumeTexture ("3d tex", 3D) = "white" {}
but unity (3.4.0) reports Null pointer exception whenever material with this property is to be shown by the inspector. Is this (undocumented) feature broken these days?
Answer by Noise crime · Jul 09, 2010 at 12:49 AM
Guess you could try exporting your 3D texture to dds format, though there appears to be some confusion as to what Unity supports with regard to dds.
As to how, nVidia have a number of tools, one of which is dds file support for Photoshop, which although supports volume textures, the documentation doesn't actually tell you how to make them. Maybe its as simple as using multiple layers?
If that fails then there are many other tools from nVidia, so might be worth checking them out.
However my first step would be to source a 3d dds from someone online and test that in Unity to check that it can be used.
edit: according to old forum threads the expected format is
The plugin used to want a horizontal image containing each slice side-by-side, arranged left to right, top slice to bottom slice.
Edit2: I'm also wondering whether
a. You could provide a 2D texture in Unity, but let it be treated as 3D? I'm assuming here that you can layout the 2D texture to match the expected format that 3D texture would follow, though you'll be restricted to non-compressed formats. Depends if a 3d texture in memory is simply one slice after another, then perhaps a vertical 2d texture say 32x1024 would be 32x32x32 3d texture. Thought this is a long shot
b. Doesn't Unity have some linkage to opengl? Perhaps you could lever that to create the 3d texture?
Thanks. 3D texture dds files are not recognized by the unity asset importer ($$anonymous$$ dds pixel format) so no luck there. The GL class has a limited API, no texture creation. I'll look at 'tricking' unity with a 2D texture with 3D layout, and hope that it somehow can work.
FYI, there's now a request on the Unity wishlist to support 3D textures: http://feedback.unity3d.com/forums/15792-unity/suggestions/2385588-support-for-volumetric-shaders
Answer by Alex Hogan · Oct 25, 2010 at 08:08 PM
I'm not sure how to load them in Unity, but the Photoshop plugin from NVidia does not seem to create volume textures - at least not correctly - at least not as far as I've been able to tell.
Try using the DirectX texture tool - it is part of the DirectX SDK. Google can show you the download link.
Your answer
Follow this Question
Related Questions
Making Unity textures/materials look as good as they did in Blender 2 Answers
Everything is invisible!,Everything turned invisible! 1 Answer
Editor Can't Able to Import 3D Model Textures 1 Answer
Imported model textures are solid colour 0 Answers
how to make gameobjects look clearer and less blurry when looking at them from farther away? 1 Answer