Skip to main content
gamedev.net
🔒 Locked

TeXturE

Started by CastorX 1 reply 400+ views
Original Post
CastorX
CastorX
Hy! There are 2 Qs. I want to create a render to texture effect. Can I create non power of 2 sized tetures (ect.: 1024*768)? Can I create textures with depth channel? THX!
MePHyst0
MePHyst0
1) theoretically you can use non-pow-2 textures as your render target if the driver supports it. But keep in mind that it will be very slow. So If you can, try to avoid non-pow-2 textures(in general, not only in this case) in all costs.

2)if you just create the RT texture, and then set is as a render target like this
device.SetRenderTarger(...)
in this case the original depth buffer will be used when rendering.

but if you additionally create a depth surface like this
device.CreateDepthStencilSurface(..)
then you can set it as :
device.DepthStencilSurface = your_surface
in this case don't forget to remember your old depth stencil surface and set it back when finished render to texture session ;)


HTH
jollyjeffers
jollyjeffers
A couple of things to extend MePHyst0's answer:

Quote:
Original post by CastorX
Can I create non power of 2 sized tetures (ect.: 1024*768)?

On most modern hardware you can, but there is no guarantee. You need to enumerate the device capabilities before creating the texture:

A call to IDirect3D9::GetDeviceCaps() or IDirect3DDevice9::GetDeviceCaps() will return a D3DCAPS9 struct - you need to query the D3DCAPS9::TextureCaps value for D3DPTEXTURECAPS_NONPOW2CONDITIONAL (device can use non power of 2 textures subject to certain conditions) and D3DPTEXTURECAPS_POW2 (device can use non power of 2 textures as normal).

Quote:
Original post by CastorX
Can I create textures with depth channel?

You can create a seperate 'depth stencil' surface as described above. An additional point when using some RTT effects is that the render target must be smaller than or equal to the size of the depth buffer. I recently wrote a program that rendered to a 2048x2048 texture - and had to create a second (matching) depth buffer to go with it, then restore the old one when I was finished [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.