x


accelerated narrowing-with-distance of objects cubemap?

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?

more ▼

asked May 06 '10 at 08:46 PM

sean gravatar image

sean
296 11 12 19

To reproduce: In the Island Demo, try putting the Reflective Bumped Unlit shader on a flat plane in front of the camera and adding the real-time cubemap script from the manual (disable the water layer from the script's rendering set, and up the cubemap resolution to at least 512 if you can). This will give you a rear-view-mirror. Cross the bridge and continue down the path to the heron beach and hang a right up the mountain. Keep an eye on the trees behind you as you walk up- past a certain point they will very clearly flatten themselves along a horizontal axis...

May 06 '10 at 08:54 PM sean
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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...

more ▼

answered May 11 '10 at 06:35 PM

sean gravatar image

sean
296 11 12 19

Er... this solves it for ~my~ purposes, anyway. It won't help if your environment map needs to be correct from any angle when seen from any angle.

May 11 '10 at 06:40 PM sean

The terrain engine flattens trees to billboards at a certain distance because otherwise you'd have 50 gazillon polygons being drawn, which would not really be acceptable.

May 11 '10 at 07:42 PM Eric5h5

Figured it was that or depth buffer disambiguation. Still, the fact that it billbaords against camera object heading even for the non-front sides of cubemaps seems like a glitch. This may not be the 'right' answer, but what would happen if they billboarded against the cameraPos->objectPos vector?

May 12 '10 at 02:21 PM sean
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x338
x81
x57

asked: May 06 '10 at 08:46 PM

Seen: 808 times

Last Updated: May 06 '10 at 08:46 PM