Jump to content
  • Advertisement
Sign in to follow this  
daVinci

Non power of 2 textures workaround

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

Hi, guys! I'm working under Image processing API now. The main problem for me is to support cards without non power of two (NPOT) support. Actually, an usual photo is NPOT. I tried to place NPOT image in a bigger POT texture and scale uv coordinates. But some my image algorithms failed =(. Ideally it would be if I could set some margin on POT texture or somehow transform samplers.. I use Direct3D9 with PixelShader 2.0 and fixed vertex processing. Please, share your experiences. Daniel

Share this post


Link to post
Share on other sites
Advertisement
Scaling the UV's won't usually work as you'll break the aspect ratio.

I've had it work fine by padding to the next POT size but just leave 'dead' space at the edge/bottom as appropriate. For example a 1600x1200 digital camera image would require a 2048x2048 texture and you'd have 448 pixels on the horizontal not used and 848 along the bottom. You then set up your texture coordinates to be 0.0-0.78, 0.0-0.58.

You may need to be careful if you're using filtering and/or wrapping, but as long as you understand that the texture coordinate should point to the *middle* of the pixel and you get your algebra right you should be fine.


hth
Jack

Share this post


Link to post
Share on other sites
What kind of problems are you having with the NONPOW2CONDITIONAL support? All pixel shader 2 cards should support this. You should also be able to overcome the texture addressing problem by using the pixel shader (for example using 'frac' to simulate WRAP addressing).

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Scaling the UV's won't usually work as you'll break the aspect ratio.

Thanks for the fast reply, Jack. I am scaling non-uniform to preserve aspect ratio. My problem was that algorithms (which perform image transform for example) do not know about my scaling and do it wrongly. For ex., "rotate at 0.5, 0.5" now this is not rotate around center. Generally this is a problem of my API architecture.

Quote:
Original post by ET3D
What kind of problems are you having with the NONPOW2CONDITIONAL support?

Thanks for the reply, ET3D. Yesterday, I reconsidered NONPOW2CONDITIONAL support and decided to allow cards with NONPOW2CONDITIONAL. But I don't have such hardware to test. I set CLAMP addressing to samplers and disable texture wrapping as well. MSDN says "dependent read and cannot be performed on these types of textures". I don't really understand it. Does it concern 1.0-1.4 shader model only? I use HLSL lang, compile as ps_2_0 target and use only tex2D. It will be alright with it?

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!