Search Unity

HDRP changing Anti-Aliasing during runtime

Discussion in 'Scripting' started by Zaelux, Apr 20, 2021.

  1. Zaelux

    Zaelux

    Joined:
    Jul 20, 2019
    Posts:
    4
    How can I change the Anti-Aliasing during runtime while using HDRP, inside a script. I wanted to make an in-game settings menu but can't get a hold of the AA.

    I found out it's on the camera as post processing, and I tried looking into documentations and guides, but nothing comes up in specifically changing it from one value to another outside of me manually changing in the editor.

    Only thing I found, which I hope is on the right track:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Rendering.HighDefinition;
    5.  
    6. public class SettingsMenuManager : MonoBehaviour
    7. {
    8.     private HDAdditionalCameraData HDCData;
    9.     public HDAdditionalCameraData.AntialiasingMode AAMode;
    10.     private FrameSettings HDCFSettings;
    11.     public GameObject HDC;
    12.  
    13.     public void checkQuality()
    14.     {
    15.         HDCData = HDC.GetComponent<HDAdditionalCameraData>();
    16.         HDCFSettings = HDCData.renderingPathCustomFrameSettings;
    17.         AAMode = HDAdditionalCameraData.AntialiasingMode.None;
    18.     }
    19. }
    20.  
    I don't know where to go from here. How could I get specifically the AA on the camera and set it to something else? The script itself doesn't do anything outside of getting some values, however, I still can't get a hold of the specific AA that is being used on the camera. While in the Editor, I can see the AAMode has it's 4 correct values, but how do I assign it to the current used AA?
     
  2. Zaelux

    Zaelux

    Joined:
    Jul 20, 2019
    Posts:
    4
    Figured it out... it's... "antialiasing"
    Code (CSharp):
    1. using UnityEngine.Rendering.HighDefinition;
    2.  
    3. public class SettingsMenuManager : MonoBehaviour
    4. {
    5.     private HDAdditionalCameraData HDCData;
    6.     public GameObject HDC;
    7.  
    8.     public void checkQuality()
    9.     {
    10.         HDCData = HDC.GetComponent<HDAdditionalCameraData>();
    11.         HDCData.antialiasing = HDAdditionalCameraData.AntialiasingMode.None;
    12.         Debug.Log($"Setting Anti-aliasing to to {HDCData.antialiasing}");
    13.     }
    14. }
    That Changes it to No anti-aliasing.
     
    Suh1ee, jjbish, mikeohc and 3 others like this.