So I have been working on a small prototype which includes spherical worlds which has provided to not be the simplest of tasks, but I am now running into an issue when it comes to using the RenderQueue, as well as with my camera controller. I have included a YouTube video showing off each of these problems.
To start with, the faked atmosphere using a simple plane and gradient texture. I have been able to achieve the desired look of the atmosphere without any issue, but I am seeing the plane being clipped by the world geometry (Which can been seen in the first part of the video). To attempt to counter this issue I created a derived MonoBehaviour which its sole purpose is to modify the render queue to render before the other objects. But this has provided either the object not being rendered entirely, or being so transparent it is hardly visible.
Directly below is the code as described above. As described in the documentation, the geometry is rendered at a place in the queue starting at 2000, so naturally I started by trying to have the plane rendered at 1999 and worked my way down from there without reaching the desired result. I am sure this issue all comes from a lack of understanding how exactly the RenderQueue functions, but any insight would be greatly appreciated.
using UnityEngine;
public class CustomRenderQueue : MonoBehaviour
{
//-------------------------------------------------------------------
#region Field
[SerializeField]
private int m_RenderOrder = 1;
#endregion
//-------------------------------------------------------------------
#region Start method
private void Start()
{
// Set render order of the GameObject
this.gameObject.renderer.material.renderQueue = this.m_RenderOrder;
}
#endregion
}
Now for the CameraController, as can be seen in the last half of the video, the camera flips 180 degrees when the controlled GameObject approaches the backside of the sphere. The controller in its current state is very simplistic, using Lerping for the position and transform.LookAt() to always have the controlled object in focus. I am fairly sure this behaviour is coming from the use of LookAt(), but I am not entirely confident as such. I’m not sure if I will have to delve into quaternions for the camera rotation, or if there is something else that I happen to be overlooking.
I would greatly appreciate any guidance on either of these two issues, thank you for your time in reading this post and look forward to hearing from the community soon!