Cinema 4D - Generating a Skybox
A skybox is a method often used in computer games to make a level look bigger than it really is. When a skybox is used, the scene is enclosed in a cube; and the sky, distant mountains, distant buildings, and other unreachable objects are projected onto the cube's six square faces using a technique called cube mapping, thus creating the illusion of distant three-dimensional surroundings.
Generating Skyboxes using "SkyBox Creator.c4d"
To generate a skybox you should first download Skybox_Generator.c4d. This is a Cinema 4D version R12 file, so if you have an earlier version you'll have to download the .c4d file Ikiman has provided here and is suitable for Cinema 4D 10 and over.
Open Skybox_Generator.c4d project and you will see a preview of the generated sky thanks to the Sky object. If you select it you can adjust the look of your sky or simply delete it and add a new one.
The camera animated to generate the six images needed for a skybox. The render settings are 1024x1024 but you can adjust that. If you press [Shift]+[R] to render, it will generate the following files in the same directory:
- skybox_image_000.tif - Front (+Z)
- skybox_image_001.tif - Back (-Z)
- skybox_image_002.tif - Left (+X)
- skybox_image_003.tif - Right (-X)
- skybox_image_004.tif - Up (+Y)
- skybox_image_005.tif - Down (-Y)
Generating your own Skybox Camera in Cinema 4D
If you'd like to skip on the template and create a skybox yourself, it's not too difficult by following these instructions:
- Open Cinema 4D
- Add a new camera (menubar: Object > Scene > Camera) and rename it "Cam_Skybox_Gen".
- With your camera selected, use the "Attributes" window to go to its "Object" tag. Change the camera's "field of view" to 90 degrees. By doing this you'll ensure all the edges of your box line up. You may also wish to reduce the "focal length" to 18, but this isn't so important.
- Go to Edit > Project Settings then change the Maximum time to 6 frames.
- On each of the six frames, set the rotation of the camera (the H, P, B) to these values:
- frame 1: 0, 0, 0
- frame 2: 180, 0, 0
- frame 3: 90, 0, 0
- frame 4: 270, 0, 0
- frame 5: 0, 90, 0
- frame 6: 0, -90, 0
Here we've setup a camera the same as in our template file, such that you only need to render the animation frames to generate the skybox. Alternatively you could create a separate camera at each of these orientations, but the only real reason you might want to do the latter is if you wanted to apply a long animation to your skybox images (not recommended).
Importing these Skybox Images into Unity
To import these skybox images into the Unity 3D game engine, create a new project in Unity and drag all the images above into your the projects Asset's folder under /Assets/Materials/MySkybox/. In the Unity Project window, select each texture and apply the following changes: change its "Wrap Mode" to Clamp, change its "Texture Type" to Advanced and uncheck "Generate Mip Maps". Now create a new material via "Create > Material" (in the Project window), change its "Shader" to RenderFx/Skybox and then drag in each text into the matching slot.... I've made it so you can just drag and drop in the same order as they appear. Finally, rename the material "my_skybox" and apply it to your scene by selecting "Edit > Render Settings" on the menubar then dragging it into the "Skybox Material" slot.
More information about Skyboxes in Unity is on this page: Unity - Skyboxes.
- Unity - Skyboxes - a page I've written about skyboxes in Unity.