24-06-2019, 06:54 AM
(22-06-2019, 01:55 AM)docgonzzo Wrote: Greetings!
I wanted to implement a "Camera Flip" mode where left is right and right is left etc. but the controls remain the same
Below is what I came up with. It gets attached to the main camera.
Everything still works and looks fine, except the 2D fluid is now invisible.
Hoping to get some hints on where i'm going wrong.
Thanks!
Code://attached to MainCamera
public bool flipHorizontal; //toggle me on/off
void OnPreCull()
{
camera.ResetWorldToCameraMatrix();
camera.ResetProjectionMatrix();
Vector3 scale = new Vector3(flipHorizontal ? -1 : 1, 1, 1);
camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(scale);
}
void OnPreRender()
{
GL.invertCulling = flipHorizontal;
}
void OnPostRender()
{
GL.invertCulling = false;
}
Hi,
The fluid renderer supports both the built-in perspective and orthographic camera projections. If you're using a custom projection, then you must also add support for it in the renderer. You can find the functions used to implement projection in Obi/Resources/ObiMaterials/ObiEllipsoids.cginc (WorldEye and VisibleEllipsoidCircleRadius functions) and ObiFluids.cginc (Z2EyeDepth and EyePosFromDepth functions).
kind regards,