Jump to content
  • Advertisement
Sign in to follow this  
Drythe

Trouble rendering to texture

This topic is 4727 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

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

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!