• Advertisement
Sign in to follow this  

RenderToSurface failure

This topic is 2458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i am trying to downsample a texture to another texture using ID3DXRenderToSurface, nothing too complicated, but all i am getting is a black texture(checked from PIX).

Here is the code:


TempRTS[3]->BeginScene();

V(HDR_FX->SetTechnique("DownSample4x4Tech"));
V(HDR_FX->SetTexture("ToBeDownSampledTexture", Full_RTS->GetTex()));
V(HDR_FX->SetValue("DownSampleOffsets", DownSampleOffsets, sizeof(DownSampleOffsets)));

UINT NumPasses = 0;
V(HDR_FX->Begin(&NumPasses, 0));
V(HDR_FX->BeginPass(0));

V(gd3dDev->SetRenderState(D3DRS_ZENABLE, FALSE));
V(gd3dDev->SetFVF(D3DFVF_SCREENVERTEX));
V(gd3dDev->SetStreamSource(0, mQuadVB, 0, sizeof(ScreenVertex)));
V(gd3dDev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2));
V(gd3dDev->SetRenderState(D3DRS_ZENABLE, TRUE));

V(HDR_FX->EndPass());
V(HDR_FX->End());

TempRTS[3]->EndScene();


some answers to some questions:
- I am rendering it outside BeginScene()
- TempRTS[3] is a RenderToSurface class i made, TempRTS[3]->BeginScene() simply calls ID3DXRenderToSurface->BeginScene() with the viewport set
- Yes, the RenderToSurface class does work. Tried it a million times before
- The viewport is the same size as the texture.
- I am downsampling a D3DFMT_A16B16G16R16F texture to a D3DFMT_A8R8G8B8
- I was using Render Targets but i got the same exact results, no results :)

As you can see, i am stuck. Anything can help now because i have been in the same spot for two days.

Share this post


Link to post
Share on other sites
Advertisement
i just missed around with the code, and it turns out. The RenderToSurface is not the problem neither is render targets. I rendered a scene to a texture with no problem using the same code(checked the rendered texture from PIX).
The problem is with the Full screen quad. Apparently whenever i try to render a full screen quad and map a texture on it, it just doesn't get any output.

The vertex buffer for the quad, and the vertices should be good

here is the vertex buffer code if you want


ScreenVertex FullVertices[] =
{
{1.0f , 1.0f , 0.5f, 1.0f, 1.0f, 0.0f},
{-1.0f, 1.0f , 0.5f, 1.0f, 0.0f, 0.0f},
{-1.0f, -1.0f , 0.5f, 1.0f, 0.0f, 1.0f},
{1.0f , -1.0f , 0.5f, 1.0f, 1.0f, 1.0f}
};
V(gd3dDev->CreateVertexBuffer(sizeof(ScreenVertex)*4, 0, D3DFVF_SCREENVERTEX, D3DPOOL_MANAGED, &mQuadVB, 0));

void* LockedVertices = 0;
//mQuadVB
V(mQuadVB->Lock(0, 0, (void**)&LockedVertices, 0));

memcpy(LockedVertices, FullVertices, sizeof(FullVertices));

V(mQuadVB->Unlock());


Is there another way to render(or create) a fullscreen quad other than this because apparently this is not working???

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement