About Downsample texture

Started by
0 comments, last by RogerRZW 11 years, 11 months ago
Hi all,

Regarding the downsampling texture, Is it mean that copying a larger texture to a smaller texture?

In my understanding we need do something like below:

1) Render scene to a full-screen sized rendertarget.
2) Downsample it to a smaller texture.
3) Use it for something like blurring.

I wrote a simple example code to verify it, but met some problems. Below is snip code of my example:


m_device->CreateTexture(m_width, m_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_diffuse, NULL);
m_device->CreateTexture(m_width*0.5, m_height*0.5, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_DownSampleTexture, NULL);
SetRenderTarget(0, m_depth);
m_effect->SetTechnique("RenderToTexture");
//Draw something
......
//Do downsampling texture
SetRenderTarget(0, m_DownSampleTexture);
PlaneVertex axPlaneVertices[] =
{
{ 0.0f, 0.0f, 0.5f, 1.0f, 0.0f, 0.0f},
{ m_width*0.5, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f},
{ m_width*0.5, m_height*0.5, 0.5f, 1.0f, 1.0f,1.0f},
{ 0.0f, m_height*0.5, 0.5f, 1.0f, 0.0f,1.0f}
};
m_effect->SetTechnique("Downsampling");
m_effect->SetTexture("SrcTex", m_diffuse);
//Render
......
m_device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
m_device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,axPlaneVertices,sizeof(PlaneVertex));
......
D3DXSaveTextureToFile("Dest.bmp",D3DXIFF_BMP,m_DownSampleTexture,NULL);



But i think there is something wrong with my code, because I want to save m_DownSampleTexture, nothing is drew on Dest.bmp.

Any help is appreciated
Advertisement
Mistake


m_device->CreateTexture(m_width, m_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_diffuse, NULL);
m_device->CreateTexture(m_width*0.5, m_height*0.5, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_DownSampleTexture, NULL);
SetRenderTarget(0, m_diffuse);

This topic is closed to new replies.

Advertisement