3D textures definition

Hi,





would it be possible to move 3d texture definition files (tex3D.j3md, tex3D.frag and tex3D.vert) to the jme core ??

I need them for generated textures to be working.





What is the chance to make these textures more functional ??

To add for example vertex colors or allow to make a normal map of it ?

In short: to make 3d textures work more or less like Lighting.j3md defined textures.

1.

Commonly, users will use flat images as textures.

But blender importer imports the generated textures as 3D textures.

So the texcoords are set to be 3d-vector.



2.

What ways of using 3d textures do you mean?

I cannot apply such texture to a model with 2d tex-coords.



3.

I was just wondering if this shader could get more functionality and more parameters.

Could 3d texture be used as a glow map or a normal map for example ?

Well those shaders are just examples, nothing really useful, it was just for the demo…also they assume the mesh has vec3 texcoord which is usually not the case. I don’t think it would work with a common model…



There are thousands of ways to use texture3D…just as much as texture2D…



I don’t really get what you mean by “to make 3d textures work more or less like Lighting.j3md defined textures.”

  1. oh? didn’t know that…well i guess it just uses the first 2 coord for 2d textures it’s not really an issue. I guess the 3D textures just have a depth of 1 right?


  2. 3D textures could be used as an alternative for texture atlases for example. It could be used for the terrain shader to be able to use more than 12 2D textures, it could be used for volume mapping (pretty much what the demo does, but very very very basic).
I cannot apply such texture to a model with 2d tex-coords.

yes you can by doing texture3d(mytexture , vec3(my2DtexCoord, 0.0)); it will use the data of the first layer of the texture. (should be always the case for 2D textures exported as 3D textures)
Could be used for sprite animations....
Really a 3D texture is just stack of 2D textures....so the only limit is your imagination (and maybe you graphic card bandwidth... :p )

3. I don't see the use for glow map of normal maps. I mean what would it bring more than a 2D texture does?

One interesting thing is that many engines that support .blend importing require the model to use UV coords (e.g. Unity3D). So even though adding this feature will give more functionality, its not that good of an idea because it will make the shader more complex and slower. Although it can be implemented via shader injection, by the way.

I heard that Shader Injection can cure cancer…too bad we don’t have that in JME3…

Actually even if we supported it, it would just be too slow. I think its best to focus on “game ready” models rather than models designed solely for raytracing or CG.

1.

oh? didn’t know that….well i guess it just uses the first 2 coord for 2d textures it’s not really an issue. I guess the 3D textures just have a depth of 1 right?


No. By default the size of 3D texture is 60x60x60.
But you can change it in blender key.

2.
Yeah, my that is not the way I'd like to use 3D textures.
Its whole idea is to use the whole texture and not only the first layer.
If I wanted to use the first layer I'd rather create 2D texture.

At first it was implemented this way. But I had problems with automatically applying UV coordinates if the user did not apply them manually (and in the case of generated textures you cannot really do it ).

3.
Well the use of normal map and/or glow map in 3d textures is the same as in a case of 2d textures.
But you may be right - if it is too slow its better to abandon it (at least for now).


I'd only like to have the shader in the core :)
I hope it is not a problem - is it?
:)
Yeah, my that is not the way I’d like to use 3D textures.

I think the problem is that I don't get how you want to use them :p
In the first place could you explain what are the generated texture by blender? why are they 3D textures?
I mean, I know there can be embedded textures in blend files, but afaik it's only 2d textures, so you might be referring to something else.


I’d only like to have the shader in the core
I hope it is not a problem – is it?

well...it's a problem if it's not relevant and consistent, and this depends of what you want to with it :p

OK



imagine you have a block of marble :slight_smile:

You take appropriate tools and carve a monkey head ( :slight_smile: ) out of it.

Your monkey head naturally is made of marble. So it looks like it is covered with a marble texture.



The same goes with blender.

Create a monkey head in blender, add a material and apply a marble texture to it.

You will see that the head will be made of that marble on your render.



But the texture that is used for it is not a flat image. It is 3-dimensional block.

In a render preview of the texture you see the flat image of course. But this is only a preview.

The real texture is larger than that.



There is a difference with covering a model with a flat texture (which is also supported by the loader) and using 3D texture for it.

Make yourself several models and try to apply generated textures as well as image textures.

You should see the difference easily. :slight_smile:

oh ok…didn’t know that, I’ll try.



Well… i guess to make it work we would have to re implement lighting using this kind of mapping technique instead of standard UV…

As Kirill said, maybe we should focus on game ready models that have proper UV since it’s the industry standard…



I understand you want to be thorough with the loader, but at some point JME won’t be able to support as much features as blender since blender is not only intended for game rendering.

I know we won’t be able to import everything.

At this moment there are many things I assued will not be imported (ie. some constraints, multiple skeletons applied to one mesh and several more).

But the generated textures add a nice piece of functionality and might be quite useful :wink:



Anyway I spent several months working and improvint that feature.

I wouldn’t like to see it discarded now when it works reasonably well :wink:

Maybe it is a good idea not to support normal maps or glow made with 3D textures due to performance reasons. I won’t argue here.



On the other hand @normen wants to use this loader to import assets from blend files.

And so the generated textures could be imported as images there :wink:

Yeah, think like assetManager.registerLocator(“MyBlendFile.blend”); → Lots of possibilities to get out jme specific data. On the other hand @neon is right, the main purpose of the loader is to load game compatible models, so that should be the main focus. But still the loader is meant to be more than just a model loader but a whole blender-jme bridge in the end so all features that can be supported should be.

If we are able to import as much as possible we can attract more people to use jMonkeyEngine in their games.

It is up to users wheather they will use 3D textures or not.

We just give them tools :wink:



On the other hand I would like to know how much these textures affect the rendering speed.

As far as I know there are native libraries that do the rendering and they support 3D texturing.

On the other hand I would like to know how much these textures affect the rendering speed.

I honestly have no idea...maybe it doesn't. a 3D texture is not necessarily bigger than a 2D one...we'll only know once tested ....

If you want to experiment with the tex3D.j3md I made, go ahead, but right now it's pretty basic and behave like the unshaded material.
Btw you can put it in the blender loader, you don't have to put it in the core (for example the terrain materials are in the terrain plugin).

OK then :slight_smile:

I’ll put it in blender loader.



Is there any editor that helps with shaders editing??

I’m not very familiar with that and could use some IDE help.

there is a GLSL syntax highlighter that can be installed in the third party plugin of JMP.

It’s a bit buggy, but it’s quite useful.



there is no magic though…just a syntax highlighter… developing shaders can be a bit painful…

Anyway feel free to ask for help

@nehon and me want to tie the GLSL highlighter and some preview UI together so its easier to develop and debug shaders. For now, you can edit shaders in a jme3 project with the GLSL editor quite easily already as nehon pointed out.

We also intend to rule the world at some point…but it’s a long shot…