• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
supersonicstar

How to initialize a D3DFMT_A16B16G16R16F texture?

7 posts in this topic

I use following code to initialize a D3DFMT_A8R8G8B8 texture, D3DCOLOR temp; for( int j = 0; j <TEX_PREC; j++ ) { for( int i = 0; i < TEX_PREC; i++ ) { temp=density(i,j); (*(DWORD*)( (BYTE*)d3dlr.pBits + ((DWORD)d3dlr.Pitch * (j)) + (i*4)))=temp; } } I tried to change it to a D3DFMT_A16B16G16R16F version. But it seems that there is no 16-bit floating point data structure for CPU program. Could anyone tell me how to do it? Thanks a lot. [Edited by - supersonicstar on March 15, 2006 10:31:29 AM]
0

Share this post


Link to post
Share on other sites
Another option is if you've set the texture up as a render target, you could render a screen aligned quad and use the pixel shader to initialize all the data to whatever value you want.

neneboricua
0

Share this post


Link to post
Share on other sites
Thank you,Scoob Droolins and neneboricua19, very helpful!

The second method may have a limitation when it comes to a volume texture. But it seems that Quadro FX 4000 GPU has the ability to render to a 3D texture(google:Technical Brief: NVIDIA HPDR Technology site:nvidia.com). However, according to dx docs(see:D3DUSAGE), the volume texture cannot be set as a render target.

Now I am facing such a problem: I have 256 slices of D3DFMT_A16B16G16R16F 256x256 2d textures(I set them as render targets, and they store the rendering result). And I hope to export these 2d textures into a 3d texture. I have not figured out any good solutions.

Anyone could give me some suggestions?
0

Share this post


Link to post
Share on other sites
Quote:
Original post by supersonicstar
But it seems that there is no 16-bit floating point data structure for CPU program. Could anyone tell me how to do it? Thanks a lot.
Yes there is - D3DXFLOAT16 [smile]

You might also be interested in this thread. It's a slightly different problem, but it's still related to reading/writing/manipulating FP16 data.

Quote:
Now I am facing such a problem: I have 256 slices of D3DFMT_A16B16G16R16F 256x256 2d textures(I set them as render targets, and they store the rendering result). And I hope to export these 2d textures into a 3d texture. I have not figured out any good solutions.
So, if I understand you correctly you want to convert a IDirect3DTexture9[256] into a single IDirect3DVolumeTexture9?

Jack
0

Share this post


Link to post
Share on other sites
Thank you, I will read that thread.:-)
Yes,I want to convert a IDirect3DTexture9[256] into a single IDirect3DVolumeTexture9.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by supersonicstar
Yes,I want to convert a IDirect3DTexture9[256] into a single IDirect3DVolumeTexture9.
Okay, have you considered the simplest possibility? IDirect3DDevice9::CreateVolumeTexture() and then use IDirect3DVolumeTexture9::LockBox() to manually compose the final volume texture, finally using D3DXSaveVolumeToFile() if you want it stored for later?

Probably won't be too speedy (especially as you're pulling data from (ex) render-targets), but you didn't mention anything about requiring it to fit a particular performance profile [grin]

hth
Jack
0

Share this post


Link to post
Share on other sites
Thanks a lot, it works fine! Here the speed is not a problem (it is a one-off post-processing of 256 slices of rendering results).

I changed it to a 16-bit floating version:
	float x1,y1,z1;
x1=-(float(VOXEL_PREC)-1)/2;
y1=-(float(VOXEL_PREC)-1)/2;
z1=-(float(VOXEL_PREC)-1)/2;

D3DXVECTOR4_16F temp;
for( int k = 0; k < LAYER_NUM; k++ )
{
for( int y = 0; y <VOXEL_PREC; y++ )
{
for( int x = 0; x < VOXEL_PREC; x++ )

{
temp=density(x1,y1,z1,1);
DWORD overall_offset=pLockedVolume.SlicePitch*k+pLockedVolume.RowPitch*y;
(*(D3DXVECTOR4_16F*)((BYTE*)pLockedVolume.pBits+overall_offset+x*sizeof(D3DXVECTOR4_16F)))=temp;
x1++;
}
x1=-(float(VOXEL_PREC)-1)/2;
y1++;
}
y1=-(float(VOXEL_PREC)-1)/2;
z1++;
}



Now there are still two things I don’t understand:

(1) It seems that the range of D3DXFLOAT16 is 0-1, for example, if density(x1,y1,z1,1) return D3DXVECTOR4_16F(100.0f,5.0f,1.7f,0.5f), when writing it to texture, this value will be cut to D3DXVECTOR4_16F(1.0f,1.0f,1.0f,0.5f).After I store the volume texture as file, and check the value of each pixel, I found that “1.0f” stands for “255”, “0.5f” stands for “128”, and so on.
I also tried D3DFMT_A32B32G32R32F texture format (and corresponding D3DXVECTOR4), the same thing happened.

(2) According to dx docs,

typedef struct D3DXFLOAT16 {
WORD Value;
} D3DXFLOAT16, *LPD3DXFLOAT16;

I’m confused whether D3DXFLOAT16 is a 16-bit floating-point type or a 16-bit unsigned integer type.

Anyone know why? Thanks.

[Edited by - supersonicstar on March 16, 2006 6:45:06 AM]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0