Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

About Downsample texture

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 RogerRZW   Members   

103
Like
0Likes
Like

Posted 20 May 2012 - 01:59 AM

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

#2 RogerRZW   Members   

103
Like
0Likes
Like

Posted 20 May 2012 - 02:36 AM

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);





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.