Very simple question, which of these two (Face towards Camera plane vs Face towards Camera position) is better performance-wise ? Alternatively, if someone has the full source code for these nodes, that would help a lot !
Thanks ~
Very simple question, which of these two (Face towards Camera plane vs Face towards Camera position) is better performance-wise ? Alternatively, if someone has the full source code for these nodes, that would help a lot !
Thanks ~
If you open package cache you can find vfx graph package somewhere and find the source code for orient block.
So camera position mode obviously needs to calculate the direction vector first (unless camera is orthographic), so it’s actually slower in theory, however the difference is so small you should not decide to use FaceCameraPlane just because it’s faster - use what you need. I doubt it could cause any performance problems, it’s only 2x normalize and 2x cross product and it runs only once per vertex. Furthermore camera position could be actually faster (or comparable) when simulation runs in world space because there is no need to normalize all 3 vectors.
FaceCameraPlane
float3x3 viewRot = GetVFXToViewRotMatrix();
axisX = viewRot[0].xyz;
axisY = viewRot[1].xyz;
axisZ = -viewRot[2].xyz;
#if VFX_LOCAL_SPACE // Need to remove potential scale in local transform
axisX = normalize(axisX);
axisY = normalize(axisY);
axisZ = normalize(axisZ);
FaceCameraPosition (note there is different version for strips)
if (IsPerspectiveProjection())
{
axisZ = normalize(position - GetViewVFXPosition());
axisX = normalize(cross(GetVFXToViewRotMatrix()[1].xyz,axisZ));
axisY = cross(axisZ,axisX);
}
else // Face plane for ortho
{
float3x3 viewRot = GetVFXToViewRotMatrix();
axisX = viewRot[0].xyz;
axisY = viewRot[1].xyz;
axisZ = -viewRot[2].xyz;
#if VFX_LOCAL_SPACE // Need to remove potential scale in local transform
axisX = normalize(axisX);
axisY = normalize(axisY);
axisZ = normalize(axisZ);
#endif
}
@Qriva Thanks a lot !
I’ve checked the folder in my project (Library/PackageCache) and couldn’t find anything in there. Is it stored somewhere else ? =X
Also, the code uses GetVFXToViewRotMatrix() and GetViewVFXPosition().
I feel these two could be pretty heavy…? Do you have an idea where they are stored ?
Thank a lot once again !
Actually I am not sure, that is strange, mine is there ProjectName\Library\PackageCache\com.unity.visualeffectgraph@12.1.6
If it’s not there, maybe you can try check global chache in %appdata%.
I don’t know, for some reason I can’t find it in the package using VSC, but I guess they are not heavy, there are probably ready to use matrices and vectors and those functions just return them. Anyway I would not be bothered, unless you are sure it will cause problems.
Note to the previous post, actually I said a bit wrong as normalization is excluded anyway if you enable world space sim.