Trouble rendering to texture

Started by
1 comment, last by Specchum 18 years, 10 months ago
I'm trying to simulate a shadow being projected onto an object and am having some problems updating the shadow texture. ok, I created the texture: D3DXCreateTexture(pDevice, 512, 512, D3DX_DEFAULT, D3DUSAGE_RENDERTARGET, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, &ShadowTexture); set the texture's surface for rendering: LPDIRECT3DSURFACE9 ShadowSurface; ShadowTexture->GetSurfaceLevel(0, &ShadowSurface); pDevice->SetRenderTarget(0, ShadowSurface); now, I called these just to make sure it was rendering the right stuff: D3DXSaveTextureToFile("moof.bmp", D3DXIFF_BMP, ShadowTexture, NULL); D3DXSaveSurfaceToFile("moof2.bmp", D3DXIFF_BMP , ShadowSurface, NULL, NULL); the image files are perfect, but for some reason, it's not outputting the same thing when I render to the scene. I'm getting gibberish... I tried a working texture to make sure the tex coordinates and rendering parameters were ok and that's all working. any help would be awesome. thanks:)
Advertisement
I had similar problems.. I assume you are rendering your scene two times and switching back to render normally after drawing the scene to the texture surface.

You should try checking the size of the backbuffer (making sure it is the same size of your render target) and / or adding (in OR) Usage AutoGenerateMipMap. My problem was that I tried to blend a scaled up (1024 x 1024) version of a texture with a 512 x 512 one. Since only the top left quadrant of the first texture was to be blended, the fact that mipmap levels were not generated caused garbage results.

Hope this helps..
--Avengers UTD Chronicles - My game development blog
How about posting the remaing bits of code? ARe you setting up the viewport properly, backand the stencil buffer and then setting back the original buffer when done?
"There is no dark side of the moon." - Pink Floyd

This topic is closed to new replies.

Advertisement