I have two types of 2d objects:
In first case (for about 70% of objects), I need that code in the shader:
float2 texCoord = input.TexCoord + textureCoord.xy
But in the second case I have to use:
float2 texCoord = fmod(input.TexCoord, texCoordM.xy - textureCoord.xy) + textureCoord.xy
I can use second code also for first case, but it will be a little slower (fmod
is useless here, input.TexCoord will be always lower than textureCoord.xy - textureCoord.xy
for sure).
My question is, which way will be faster:
- Making two independent shaders for both types of rectangles, group rectangles by types and switch shaders during rendering.
- Make one shader and use some if statement.
- Make one shader and ignore that sometimes (70% of cases) I don't need to use
fmod
.