I'm playing with a hack of the Island Demo that has me more or less looking at the world through a real-time cubemap. I just noticed that objects like the palm trees seem to rapidly narrow themselves into invisibility past a certain distance. For instance, I can back away from the beach up a mountain path and at some point each tree-cluster individually will start rapidly shrinking on x and/or z while retaining its proper-for-distance height, before popping out entirely. The cubemap camera is set to the same clipping depth as my main camera (2000), and yet the main camera renders fine from the same position.
I could see this being a Unity optimization to discreetly reduce the amount of content rendered to cubemaps. I could also see it being a bug in the cubemap render transforms that hasn't been caught because most folks aren't pathological enough to be using a real-time cubemap as their primary view of a world. Anyone have any idea what's up?
Hm. Suspicions confirmed- the objects are flattening themselves to bilboard against the heading of the rendering camera. Popping a cam.transform.rotation tweak into the UpdateCubemap function:
function UpdateCubemap (faceMask : int) {
if (!cam) {
var go = new GameObject ("CubemapCamera", Camera);
go.hideFlags = HideFlags.HideAndDontSave;
go.transform.position = transform.position;
go.transform.rotation = Quaternion.identity;
cam = go.camera;
cam.farClipPlane = farClippingPlane; // don't render very far into cubemap
cam.enabled = false;
//cam.cullingMask = ~(1<<4) & m_ReflectLayers.value; // never render water layer
//cam.cullingMask = ~(1<<8) & m_ReflectLayers.value; // never render self
cam.cullingMask = m_ReflectLayers.value;
//cam.depth = 2;
}
if (!rtex) {
rtex = new RenderTexture (cubemapSize, cubemapSize, 16);
rtex.isPowerOfTwo = true;
rtex.isCubemap = true;
rtex.hideFlags = HideFlags.HideAndDontSave;
renderer.sharedMaterial.SetTexture ("_Cube", rtex);
}
cam.transform.position = transform.position;
cam.transform.rotation = transform.rotation;
cam.RenderToCubemap (rtex, faceMask);
}
seems to eliminate the visible symptom (yeah, there are some extra commented-out lines in there that I was playing with to solve ~other~ issues).
I'm still curious as to why the engine does this to begin with, and whether it happens on all renders or just cubemap renders...