Finding the box camera frustum gives the wrong impression as you bump into distant objects diagonally that then disappear when you look at them.
Would it not be more natural to have a radial camera frustum?
Finding the box camera frustum gives the wrong impression as you bump into distant objects diagonally that then disappear when you look at them.
Would it not be more natural to have a radial camera frustum?
The problem is the planar projection of the camera. Its an approximation that works sufficiently well for small FOVs but quite bad for larger FOVs. What you would want to have is a camera with spherical projection, but in this case straight lines arenât straight lines anymore which makes it much harder to render. (ray tracing does not have this issues, since they are transforming points not lines)
A solution to your problem would be to compute the fragment distance from the camera in the shader and âclipâ far objects by hand instead of relying on far plane clipping in the pipeline.
What about an array of 4 (2x2), 9 (3x3) , 16 (4x4) cameras each providing a render tile/segment of the main display with their frustums aligned and distorted to provide a âcurved frustumâ?
You might want to look into these:
https://docs.unity3d.com/ScriptReference/Camera-layerCullSpherical.html
That could work but looks like you need to set up culling distances.
Enabling spherical culling will cull objects spherically, but thatâs different than the clip plane. If youâve got a lot of large objects or batched meshes it wonât really change anything.
Using multiple cameras is an option if you also want the spherical lens distortion, that kind of technique has been used in the demo scene for the last decade to create fisheye effects, but it requires a lot of cameras to get good results, 4x4 wonât be enough, more like 16x16. Rendering 256 cameras in Unity at the same time is going to destroy your performance.
If all youâre after is a spherical distance plane and you donât actually need a spherical camera distortion then youâre better off using a spherical fog or calculating a spherical clip plane in the shader.
I believe the Global Fog already does spherical fog, but the default forward fog does not. If youâre already using custom shaders you can just use your own fog, or override the fog distance calculation in UnityCG.cginc and put that in your shader folder alongside your custom shaders.
#define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) UNITY_CALC_FOG_FACTOR(length(coord.xyz)); UNITY_FOG_LERP_COLOR(col,fogCol,unityFogFactor)
If your clip plane is close enough that it is really the problem, then youâll want to calculate the distance from the camera and use clip() in your fragment shader.
// vertex shader
o.viewPos = mul(UNITY_MATRIX_MV, v.vertex); // calculate camera relative position
// fragment shader
clip(_ProjectionParams.z - length(i.viewPos.xyz)); // clip if position is further than far plane, but spherically instead of just in projection space
Alternatively if youâre passing the world position you could use length(i.worldPos.xyz - _WorldSpaceCameraPos.xyz) in place of i.viewPos.xyz.