- Home /
Calling Render() twice using the same camera
Hello, I am trying to create a 3D repeating space (think asteroids but 3D). To achieve this effect I call Render() twice at two different positions using the same camera without clearing but changing the farClip distance, but only when the camera is near the "end of the world" (sphere).
In the example below, the blue box is behind the red one; since the camera renders the red one first (and at a closer distance) it appear to be in front:
As you can see it works fine in the built version, however in the editor it only displays the first Render() call (and that is only the case if I leave the camera enabled).
Is there a better way to achieve this effect or fix the editor version to display like the built version does?
Tried placing it in: update and postRender - same result.
void OnPostRender()
{
pos = transform.position;
cam.clearFlags = CameraClearFlags.Skybox;
cam.farClipPlane = 40.0f;
cam.Render();
cam.clearFlags = CameraClearFlags.Nothing;
transform.position -= new Vector3(120.0f, 0.0f, 0.0f);
cam.farClipPlane = 80.0f;
cam.Render();
transform.position = pos;
}
Your answer
Follow this Question
Related Questions
HDRP Camera weapon layer 1 Answer
Render White Pixels as Transparent 2 Answers
How to get screen coordinates of object from shader 0 Answers
main camera destroying in editor but not in android 1 Answer
Showing/Visualizing the camera cone 3 Answers