Sign in to follow this  
wildboar

Sampling 1x1 texture vs if statements

Recommended Posts

I am programming for the ipad 3 and my material system currently checks if a texture is applied to a material slot, if its not then it uses default 1x1 white pixel as a sample in the shader. The shader samples 4 textures like this and combines them. Is this an ok way to do it or should I use if statements (if texture 2 is attached then sample).

Also does anyone know why sampling a depth texture is so damn slow on ipad 3? its a 768x768 texture that is a static shadow map. As soon as I enabe sampling of it fps drops by at least 10.

Share this post


Link to post
Share on other sites
A drop by 10 fps may or may not be slow depending on what kind of framerate you were getting beforehand. At the same time, you may have weak non-power-of-two support so padding the texture out to 1024x1024 might enable your driver and/or hardware to take a more optimized path.

Regarding your first question, I'd be inclined to go with the 1x1 texture as it would give you cleaner code and less state changes. You're not clear however on whether the if statement would happen in a shader or in your C/C++ code so it's difficult to form any kind of overall recommendation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this