Where is the best place for Tangent-bitangent calculation, in shader or in C/CPP code? I have two methods of calculating tangent and cotengent (needed for normalMap lighting calculation).


The one is doing it from CPP code (with assimp library for example)
The second is doing it directly in shader (in Vertex shader/in fragment shader)


What is the best optimized method? (optimized for speed, with vsync activated)

I use Opengl 3.3+
Doing it in the CPU side during initialization is what I'd go for, this is assuming you are initialising that data once and passing it to the GPU.

On the GPU side, doing the calculations per fragment would be too costly and should be out of the question, unless it's really needed for a special effect then you shouldn't add unneeded ALU work to the fragment shader, this will only cause your application to slow down. On the vertex shader is more acceptable but again if you have highly tessellated geometry, it'll be expensive. 

Whenever there is data that you can compute just once, then go for that instead of doing it every frame. Even if you were planning on doing it just once on the GPU and using transform feedback or an FBO to store the data, I think this approach would be more costly. As always though, profile your application, careful tradeoffs are specific to architectures.