float3 forward = normalize(light_dir);float3 up = float3(0,1,0);float3 v_right = normalize(cross(up, forward));float dotRP = dot(v_right, light_pos);float dotUP = dot(up, light_pos);float dotFP = dot(forward, light_pos);float4x4 parab_matrix = { v_right.x, up.x, forward.x, 0.0f, v_right.y, up.y, forward.y, 0.0f, v_right.z, up.z, forward.z, 0.0f, -dotRP, -dotUP, -dotFP, 1.0f};
It works pretty fine except cases when objects direction and "up" vectors are almost the same, so it gives a gimbal lock. Is there any other way how this can be achived?
I was thinking to use quaternions for this but it looks like it will hit performance too much.