I never faced this issue but I can imagine a path.
Compute on the cpu and save on mateial skills a 2d rotation matrix related to camera inverse pan and apply to every tree sprite xz members before converting to clip space into the vertex shader.
EDITED
I just realized this method will not work with trees merged in a single entity, as they should be if you look for performance optimitation. The solution could go around saving the rotation axe in object space for each vertex into the buffer.
EDITED 2
Since I am interested in these things I did a test workaround.
I created a model procedurally of 126^2 face trees. I added the center of rotation for each vertex to the vertex buffer. Secondary uv coords or x3-y3. Both worked.
I compute the sine and cosine of the camera pan in the main loop and save into material skills. The faces all look to the -X axe so rotating them by the camera pan makes them visible parallel to the projection plane.
mtlTreeSprites->skill1 = floatv ( sinv ( camera->pan ) );
mtlTreeSprites->skill2 = floatv ( cosv ( camera->pan ) );
void TreesVS (
in float4 InPos : POSITION,
in float2 InTex : TEXCOORD0,
in float2 InOffset: TEXCOORD1,
out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0 )
{
float2 pos = InPos.xz - InOffset.xy;
InPos.xz = float2 ( pos.x * vecSkill1.y - pos.y * vecSkill1.x, pos.x * vecSkill1.x + pos.y * vecSkill1.y ) + InOffset.xy;
OutPos = mul ( InPos, matViewProj );
OutTex = InTex.xy;
}
It works well.
Salud!