Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 677 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
3d texture #421207
04/13/13 14:24
04/13/13 14:24
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
hey there,
Does anyone know how to use 3d textures properly?

I used the gimp .dds plugin to save a 32³ volume map and I read the texture color by using tex3D but somehow it doesn't work.
(it behaves like a 2D texture and just uses the first layer)


POTATO-MAN saves the day! - Random
Re: 3d texture [Re: Kartoffel] #421213
04/13/13 17:57
04/13/13 17:57
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline
User
BoH_Havoc  Offline
User

Joined: Jun 2004
Posts: 655
to your left
As the Photoshop .dds plugin also doesn't really work for me (when trying to create 3D textures, everything else works fine), i always use DxTex.exe from the DirectX SDK to do the job. Works great. laugh


Shade-C EVO Lite-C Shader Framework
Re: 3d texture [Re: BoH_Havoc] #421215
04/13/13 18:15
04/13/13 18:15
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Thanks a lot, I'll try it!


POTATO-MAN saves the day! - Random
Re: 3d texture [Re: Kartoffel] #421220
04/13/13 19:30
04/13/13 19:30
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I tried it but somehow it still doesn't work...

Do I have to mind anything special? like special texture coordinates when using tex3D?

EDIT: I'm using it like this:
Code:
texture tLUT_bmap;
sampler3D smpLUT = sampler_state
{
	Texture = <tLUT_bmap>;

	Filter = Linear;
	
	AddressU = Clamp;
	AddressV = Clamp;
	AddressW = Clamp;
};

[...]

Color.rgb = tex3D(smpLUT, Color.rgb).rgb;


If I use the screenspace coordinates as texcoords and change the z-coordinate it always displays the first slice.

Edit: maybe a BMAP * can't handle volume textures?

Last edited by Kartoffel; 04/13/13 20:22.

POTATO-MAN saves the day! - Random
Re: 3d texture [Re: Kartoffel] #421239
04/14/13 10:37
04/14/13 10:37
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline
User
BoH_Havoc  Offline
User

Joined: Jun 2004
Posts: 655
to your left
As far as i know you can't simply use BMAP* the traditional way to load volume textures.
Here's how i do it:

Code:
STRING* sc_deferredLighting_sBRDFLUT = "shadec/tex/sc_deferredLighting_LUT.dds";
LPDIRECT3DVOLUMETEXTURE9* sc_deferredLighting_texBRDFLUT;

LPDIRECT3DVOLUMETEXTURE9 sc_volumeTexture_create(STRING *filename)
{
	LPDIRECT3DVOLUMETEXTURE9 temptex;
	HRESULT res = D3DXCreateVolumeTextureFromFile((LPDIRECT3DDEVICE9)pd3ddev, _chr(filename), &temptex);
	if(res != S_OK)
	{
		printf("error: %x", res);
		return NULL;
	}
	return temptex;
}

//create brdf LUT
if(!sc_deferredLighting_texBRDFLUT) sc_deferredLighting_texBRDFLUT = sc_volumeTexture_create(sc_deferredLighting_sBRDFLUT);

//In your material event
LPD3DXEFFECT pEffect = (LPD3DXEFFECT)render_d3dxeffect;
pEffect->SetTexture("texBRDFLut", sc_deferredLighting_texBRDFLUT); //assign volumetric brdf lut



I think you can also directly set it to BMAP.d3dtex once you loaded it using sc_volumeTexture_create() but i'm not sure.

The texcoords for fetching the volume slide are in range 0-1. In order to fetch a slide from a volume texture with a depth of 32 you can fetch that by x/32.
Also, if i remember correctly, you always have to use a power of 2 for your volume depth. Volume textures with 3,5,6,7,9,etc slides won't work. I may be wrong on this, but something in my mind tells me it was this way when i used volume textures with gamestudio.

Hope this helps! laugh

[edit] Here's the missing stuff
Code:
// Original code by Nils Daumann | www.slindev.com
// http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=357697&Main=42496#Post357697

#undef INTERFACE
#define INTERFACE IDirect3DTexture9

DECLARE_INTERFACE_(IDirect3DVolumeTexture9, IDirect3DBaseTexture9)
{
    /*** IUnknown methods ***/
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE;
    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
    STDMETHOD_(ULONG,Release)(THIS) PURE;

    /*** IDirect3DBaseTexture9 methods ***/
    STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice) PURE;
    STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE;
    STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE;
    STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE;
    STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE;
    STDMETHOD_(DWORD, GetPriority)(THIS) PURE;
    STDMETHOD_(void, PreLoad)(THIS) PURE;
    STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE;
    STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE;
    STDMETHOD_(DWORD, GetLOD)(THIS) PURE;
    STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE;
    STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE;
    STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE;
    STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE;
    STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE;
    STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,void** ppSurfaceLevel) PURE;//IDirect3DSurface9
    STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE;
    STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE;
    STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE;
};

MY_DECLARE_INTERFACE(IDirect3DVolumeTexture9)
typedef IDirect3DVolumeTexture9 *LPDIRECT3DVOLUMETEXTURE9;

HRESULT WINAPI
    D3DXCreateVolumeTextureFromFileA(
        LPDIRECT3DDEVICE9         pDevice,
        LPCSTR                    pSrcFile,
        LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);

#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA


Last edited by BoH_Havoc; 04/14/13 11:08.

Shade-C EVO Lite-C Shader Framework
Re: 3d texture [Re: BoH_Havoc] #421242
04/14/13 10:48
04/14/13 10:48
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Yes this helps a lot.

The default d3d9.h doesn't include LPDIRECT3DVOLUMETEXTURE9 but I just saw that it's declaration is in sc_volumeTexture.c & .h from shade-c.

I'm going to try it and I'll let you know if it works.


POTATO-MAN saves the day! - Random
Re: 3d texture [Re: Kartoffel] #421257
04/14/13 12:45
04/14/13 12:45
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Works perfectly, thank you very much.


POTATO-MAN saves the day! - Random

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1