Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Blurry Panorama Capture in HDRP Setup

Discussion in 'High Definition Render Pipeline' started by sophiekergassner, Jun 12, 2023.

  1. sophiekergassner

    sophiekergassner

    Joined:
    May 5, 2023
    Posts:
    2
    Hi guys,

    I want to render a panoramic image from the "3D Sample Scene HDRP" with this code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PanoramaCapture : MonoBehaviour
    6. {
    7.  
    8.     public Camera targetCamera;
    9.     public RenderTexture cubeMapLeft;
    10.     public RenderTexture eqirectRT;
    11.     public KeyCode actionKey;
    12.  
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.         if (Input.GetKeyDown(actionKey))
    17.             Capture();
    18.     }
    19.  
    20.     public void Capture()
    21.     {
    22.         targetCamera.RenderToCubemap(cubeMapLeft);
    23.         Save(cubeMapLeft, "Cube");
    24.         cubeMapLeft.ConvertToEquirect(eqirectRT);
    25.         Save(eqirectRT, "Panorama");
    26.     }
    27.  
    28.     public void Save(RenderTexture rt, string filename)
    29.     {
    30.         Texture2D tex = new Texture2D(rt.width, rt.height);
    31.         RenderTexture.active = rt;
    32.         tex.ReadPixels(new Rect(0, 0, rt.width, rt.height),0,0);
    33.         RenderTexture.active = null;
    34.  
    35.         byte[] bytes = tex.EncodeToJPG();
    36.  
    37.         string path = Application.dataPath.Replace("/Assets", "") + "/PanoramaCaptures";
    38.  
    39.         if (!System.IO.Directory.Exists(path))
    40.             System.IO.Directory.CreateDirectory(path);
    41.  
    42.         path = path + "/"+filename + ".jpg";
    43.         System.IO.File.WriteAllBytes(path, bytes);
    44.  
    45.         Debug.Log("File saved: " + path);
    46.  
    47.     }
    48. }
    However, the image looks blurry, kind of like a motion blur.
    Panorama.jpg
    This is what the exported cubemap looks like (the problem already occurs there):
    Cube.jpg

    I tried the PanoramaCapture in other basic scenes is created, there it works perfectly. The camera i tried it with was the standard MainCam from the scene, as well as another Camera I just created from scratch. Both didn't work. I didn't dive deep into HDRP yet, so I'm just guessing that this might be the problem..?

    Does anyone has an idea how to solve this? Or is there another way to capture panoramic images in this scene?

    Thanks!
    Sophie
     
    Last edited: Jun 12, 2023
  2. sophiekergassner

    sophiekergassner

    Joined:
    May 5, 2023
    Posts:
    2
    I found this thread and I just unchecked "Motion Blur" under "Edit -> Project Settings -> HDRP Global Settings". This temporary solution works perfectly fine for me. :)

    Screenshot 2023-06-12 174620.jpg
     
    Last edited: Jun 12, 2023
  3. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    692
    Better yet, you can disable MotionBlur only on the "targetCamera" by clicking "Custom Frame Settings" and unchecking MotionBlur there. That way, it's overriden but only for this specific camera.
     

    Attached Files:

    shwhjw likes this.
  4. shwhjw

    shwhjw

    Joined:
    Mar 15, 2016
    Posts:
    70
    This is the only thing that worked for me, modifying the HDRP settings didn't have any effect. Thanks!