I’m using tanh (extensively for neural net simulation) from a CG shader. Under Unity 4 on my Macbook Pro this was fine unless I included #pragma glsl in which case hyperbolic functions would report an error of “no matching overloaded function found”. But now under 5.0 on OpenGL shaders are always compiled into GLSL even without the pragma. To quote the update notes:
“On desktop OpenGL, shaders are always compiled into GLSL instead of ARB_vertex/fragment_program target now. You no longer need to write “#pragma glsl” to get to features like vertex textures or derivative instructions. All support for ARB_vertex/fragment_programs is removed.”
I can see that the shaders are still compiling for D3D but not for OpenGL or OpenGL ES. How do I go about getting hyperbolic functions to compile into glsl in Unity?
Update: I tried a messy workaround by providing a separate native GLSL subshader to avoid the conversion from CG but this resulted in the error: “Invalid call of undeclared identifier ‘tanh’”. Thinking this might be due to the default version number being too low I tried setting version within the subshader but got an error message that #version needed to be at the top of the program even though it was at the top of the subshader. So, still no way to get hyperbolic shader functions for OpenGL in Unity 5.0.