Search Unity

Camera.RenderToCubemap - can it capture relative rotations based on the camera rotation?

Discussion in 'Editor & General Support' started by Dreamback, Nov 12, 2018.

  1. Dreamback

    Dreamback

    Joined:
    Jul 29, 2016
    Posts:
    220
    I'd like to do a RenderToCubemap in the direction the camera is pointing, meaning +Z is camera.transform.forward (or -Z would work too). In realtime I'm using RenderToCubemap followed by ConvertToEquirect to get a spherical 360 degree render, so I can read the values of pixels on the sphere around the camera as the game is running. But my code would be quite a lot simpler if the directions matched the camera perfectly; is there an easy way to do this?

    I tried capturing my own cubemap by doing 6 Camera.Renders, rotating the camera between each one and copying the results to a RenderTexture that was a cube, and the results were what I wanted, but that was far slower than camera.RenderToCubemap, which is already pretty slow.
     
    crookookoo likes this.