I’m working again (after more than 1 year) on my ocean shader (yes… I know there is community ocean now… but I like to explore something different ).
Using waves (a lot of waves) my material performs a lot of sine/cosine operations for each vertex of a high tesseleted mesh, so I asked myself “is it possible to make sine/cosine faster?”.
Instead of approximating the value using some other formula, I’ve created a 256x2 pixel lookup texture containing a greyscale “sine” (with a viewport screenshot at first, with a DrawMaterialOnRenderTarget then) and I use it to output the value of a sine (for example, put a Time node as UV and you’ll have a 1 second period sine).
So… it works! Sine and cosine with no difference (at first glance) from the standard node.
But my question is: the instruction count is a little higher with my system, but I suspected that look up a texture could be faster than compute a real sine… Am I wrong?
What do you think about that?
Please remember that my idea is to optimize a material with a lot of sine/cosine nodes… of course the standard node will be better for simpler shaders.