Posted: 23rd Jun 2007 20:08
I've just been experimenting with producing 3D volume textures and shaders but then couldn't see how to load the textures into DBPro. As far as I can tell, DBPro supports regular 1D and 2D textures and 3D cube maps, but not 3D volume textures.

Is this correct? Or have I missed something?
For example, does anyone know if there's an undocumented flag on the "load image" command that I've missed? (The texture mode flag of 2 is only for cube map textures, not volume textures.)
Posted: 24th Jun 2007 11:57
Well, I think 3d volume textures can be used at a DBPro program, but they must be loaded and applied/used within a shader code.
Posted: 24th Jun 2007 14:58
but they must be loaded and applied/used within a shader code.


Thanks for the suggestion - I didn't think of trying that.

I'll give it a go and report back.

Edit:

Sorry. It doesn't seem to work - the texture is just black. It was worth a try though.

If you've got a demo that works I'd like to see it.

I think this is the same problem we have with texture shaders (i.e. "procedural" textures) - these are not currently supported by DBP either.
Posted: 25th Jun 2007 13:19
I don't have any full demo prepared, sorry.

However, I'd bet that this should work, as I remember to discard it because the 3d textures were too huge, and it was almost impossible to produce my own ones.

To declare it at the shader(hardcoded ), it was something like this:
+ Code Snippet
texture Volume_Tex
<
   string ResourceName = "Volume.dds";
>;
sampler Volume = sampler_state
{
   Texture = (Volume_Tex);
   ADDRESSU = WRAP;
   ADDRESSV = WRAP;
   ADDRESSW = WRAP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};


To recover a value from the 3d texture at the vertex shader, this was working:

+ Code Snippet
//pos: TEXCOORD0
float Volume0 = tex3D(Volume, pos);


Does that help you?
Posted: 25th Jun 2007 21:33
Does that help you?


No. I have several shaders which correctly handle volume textures in FX Composer (using code similar to your snippets - see attached FX files - both of which do nothing much except test the idea) - but none of them work seem to work in DBP.

If you can get the demo one working correctly in DBPro, I'd be very interested to see how.

as I remember to discard it because the 3d textures were too huge


Yes, useful 3D textures tend to be huge (e.g. 9MB for a simple 128x128x128 image). But size isn't the issue here.

, and it was almost impossible to produce my own ones


It's very easy if you have FX Composer. Just write a texture shader (i.e. a "procedural texture") and save the resulting image. For testing purposes you can make simple 8x8x8 volume textures and try using those in DBP. One of the shaders in the attached zip file shows you how to do it.
Posted: 26th Jun 2007 13:12
I'll try to test your shader, as I don't see anything wrong with it at first glance.

But I'm really short of time, so if you could post the .dba code for running it, I could be helping you quicker.
Posted: 26th Jun 2007 16:29
I just seems to be getting harder everyday.
Volume textures would be great for rendering puffy clouds.

I was trying to create the same effect using bumpmapping but my work PC crashes, where is the 'bump mapping available' command

and DBP doesn't support bumpmapping or scrolling textures on a matrix.

and my Ghost Object, Set Alpha.... is all over the place

Is it just me or has DBP just gone tits up???
Posted: 26th Jun 2007 17:18
But I'm really short of time, so if you could post the .dba code for running it, I could be helping you quicker.


Thanks. I'll get an example, with reasonable sized media, posted later today. The DBP code won't actually be working correctly of course.

Volume textures would be great for rendering puffy clouds.


One reason I was working with them.

Is it just me or has DBP just gone tits up???


Could be the PC as well. Happens to me all the time.
Posted: 26th Jun 2007 19:48
Volumetric textures could have so many applications. Volumetric fog, lighting, spell effects, water, the uses are limitless. I do not know how it could be accomplished without a shader (in dbp anyways), however I know that Torque accomplishes it without a shader. I don't have much to offer other than enthusiasm to this thread Hope you guys find a solution!
Posted: 26th Jun 2007 22:24
I am going camping this weekend, I am taking my laptop, so I will have a go at this also.
Posted: 27th Jun 2007 1:50
@Morcilla

Success!!

I owe you a big THANK YOU.

While I was preparing a demo to show you that your idea won't work - I realised it WAS working. No idea what I did wrong before.

I attach a simple demo with a 64x64x64 volume texture. As you say, the texture is loaded correctly if you rely on the shader code loading the texture rather than DBP.

For those interested in how to create such textures, I also include the shader I used to create the texture (it actually creates 3 textures but I only saved the third one for the demo). You need FX Composer to run that particular shader.

When you run the DBP demo, you should initially see a green sphere (the colour around the centre of the volume texture). If you press "c" the colour will eventually change to red (the colour around the surface of the volume texture). The colour will then start to change to a mixture as a result of the texture wrapping in the shader. If you press "d" the colour will eventually revert to green again.

Your help means that I can get to work on a volumetric cloud shader which I've wanted to do for ages.
Posted: 27th Jun 2007 4:05
Forgive my ignorance - but first I thought you were doing some weird thing with sound "Volume Shader"... hahha... now that I know what you mean ... sorta - I'm asking if they are a way to get more "shape" using something other than polygons? (Like the cloud thing?) Or is a morphing effect? I don't have the fx composer thing - maybe I should look rather than ask. Sounds neat though - especially if it doesn't tax the gfx card and cpu to much

Jason
Posted: 27th Jun 2007 6:46
I see a green dot. I don't get it.
Posted: 27th Jun 2007 12:44
I see a green dot. I don't get it.


So do I. Did you try holding down the "c" key as instructed? The colour should eventually change through green to red i.e. when "layer" reaches about 1. Beyond that the colours start to do weird things because of the texture wrapping. You can press "d" to bring down the value. The volume texture consists of lots of coloured concentric spheres, with the inner ones green and the outer ones red. Nothing more exciting than that I'm afraid.

The whole point of this demo was to demonstrate how to use a volume texture with a shader, nothing more.
Posted: 27th Jun 2007 14:24
JipijipiJoooOOOooo

So glad to hear that you got it working!

To have a shader that produces volume textures is already a great advance, congratulations.

Just please keep us informed about that fantastic volumetric cloud shader, and again, good job!