3 registered members (AndrewAMD, Quad, M_D),
1,217
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Support for volume textures
[Re: Hummel]
#348639
11/28/10 21:01
11/28/10 21:01
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Signed. I'm sick of seeing white-papers that mention volume textures and never looking at them again.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Support for volume textures
[Re: JibbSmart]
#348644
11/28/10 21:23
11/28/10 21:23
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Please tell me one common application for volume textures, I am not TOO familiar with them.
I thought once that they can be quite attractive for storing several maps (diffuse, normal, specular, etc.) into one texture, but after I heared that mipmaps are done also on the layers (e.g. mip0 512x512x4 --> mip1 512x512x2), they were quite uninteresting for me. Isn't it so??
Thanks for your patience.
[EDIT] Or are there other ways to store several maps in one texture without losing layers on mip maps with volume textures??
Last edited by HeelX; 11/28/10 21:23.
|
|
|
Re: Support for volume textures
[Re: ventilator]
#348658
11/29/10 02:21
11/29/10 02:21
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
OP
Expert
|
OP
Expert
Joined: Oct 2003
Posts: 4,131
|
well, a common application is 3D noise. One can easily make a 3D noise volume texture of say, 64*64*64 and sample it using tex3D(3dsampler,position.xyz). Because you are sampling a 3D texture it is consistent across space and time. 3D noise is useful for things like volumetric fog, fractal terrain, planets, etc. Currently I'm working a planet renderer in A8 using 3D noise to procedurally generate terrain on a sphere.
|
|
|
Re: Support for volume textures
[Re: jcl]
#357672
02/08/11 01:42
02/08/11 01:42
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Heyo, I don't like to bump stuff, especially when you've already said "yes", but I just haven't seen any mention of this on forecast or the beta page, and it's something I'm really itching for now that I use noise textures for explosion effects (and they'd be much more versatile with volume textures). I know you guys have a project you're working on, but is there any chance you can think of an excuse to use volume textures in Dagobert? Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Support for volume textures
[Re: JibbSmart]
#357697
02/08/11 12:24
02/08/11 12:24
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
Well, I don´t want to give jcl a reason to not implement it, but for now, you can go with something like this, Julz:
#ifndef shd_voltex_c
#define shd_voltex_c
#include <d3d9.h>
#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
// Creates a volume texture from the given filename
LPDIRECT3DVOLUMETEXTURE9 shd_voltex_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;
}
#endif
That creates the volume texture which then only has to be linked to a shader, like this for example:
// Material event assigning the texture to the shader
void shd_voltex_set()
{
LPD3DXEFFECT A7_eff = (LPD3DXEFFECT)render_d3dxeffect;
if(A7_eff != NULL)
{
A7_eff->SetTexture("voltex", (LPDIRECT3DVOLUMETEXTURE9)mtl.skill1); //"voltex" is the textures name within the shader, mtl.skill1 is missused as a pointer to the texture
}
}
//Usage:
somematerial.event = shd_matevent_colorGrading;
somematerial.flags |= ENABLE_VIEW; //for a pp effect, probably ENABLE_RENDER when applied to entities
somematerial.skill1 = (var)shd_voltex_create("yourvoltex.dds"); //creation of the volumetexture, returns LPDIRECT3DVOLUMETEXTURE9
I am not sure, but I think that it will automatically be destroyed by, when the engine destroys the directx interface or whatever thingy.
|
|
|
Re: Support for volume textures
[Re: Slin]
#357720
02/08/11 14:21
02/08/11 14:21
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Wow, Nils, thanks for that! I'll have a look into using it Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|