- Home /
Render the scene into a cubemap, adding a shader and show on display (using just one camera!)
Hey guys, i have the following intention:
I want to render the scene with the camera into a cubemap
private Camera _recorder;
private Cubemap _cube;
...
this._recorder.RenderToCubemap(this._cube);
Shader.SetGlobalTexture("_Cube", this._cube);
and after that i want to use this cubemap inside of a shader via
Graphics.Blit(source, destination, this._cameraSimulationShader, -1);
after i used the shader and modified the output, i want to print everything to the display. At the moment i solved it with 2 cameras:
public class FisheyeOutput : MonoBehaviour
{
[SerializeField]
private Material _shader;
[SerializeField]
private Camera _recorder;
private Camera _viewer;
Cubemap _cube;
private void Awake()
{
this._cube = new Cubemap(256, TextureFormat.RGBA32, false);
this._recorder.targetDisplay = -1;
}
private void Start()
{
this._viewer = gameObject.GetComponent<Camera>();
this._viewer.name = "Camera";
this._viewer.aspect = 1280.0f / 1080.0f;
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
this._recorder.RenderToCubemap(this._cube);
Shader.SetGlobalTexture("_Cube", this._cube);
Graphics.Blit(source, destination, this._shader, -1);
}
}
The camera named "viewer" shows the final image to the display, and the camera named "recorder" renders the scene into a cubemap. Do you have some ideas, how to get rid of the "recorder"-camera, so that i only use the camera I attached the script to?
Thanks in advance!
Your answer
![](https://koobas.hobune.stream/wayback/20220612183411im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Render into cubemap with a camera that has a replacement shader and convert to equirectangular 0 Answers
Image Effect - Screen coordinates 1 Answer
Equirectangular camera projection of a scene in Unity 0 Answers
Render everything in black, but the enemies in red 2 Answers
Best way to swap between view modes 0 Answers