Shaders: How heavy is tex2D()?

I want to use tex2D extensively on a shader, since I want to mess a lot with UV’s. The texture is always the same, but I use tex2D to deform it and add one above the other. How heavy is to use this function inside a shader? Please note that I’m developing for mobile.


Not quite sure what units of “heaviness” you expect people to answer with: medium-heavy? 3/5 heavy?! You really need to profile your own application to answer the question.

Texture lookups themselves are not that taxing for modern chips - even mobile devices. However, one thing to note is that by “messing with the UVs”, it sounds like you’re going to be doing dependent texture reads - i.e. ones in which the uv coordinates are dynamically assigned within the shader itself. This means the texel data can’t be pre-fetched, and will lead to a slowdown. It’s explicitly discouraged in the iOS shader guidelines here: Best Practices for Shaders

General shader best practice obviously still applies - do as much in the vertex shader as possible.