Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback it would be nice to have a raytracing toggle in the scene view

Discussion in 'HDRP Ray Tracing' started by laurentlavigne, Mar 20, 2020.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    because raytrace can be so non interactive
    upload_2020-3-19_17-8-16.png
     
    Lex4art likes this.
  2. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Good idea.
     
  3. auzaiffe

    auzaiffe

    Unity Technologies

    Joined:
    Sep 4, 2018
    Posts:
    255
    Hi,

    Currently to do that, you can disable ray tracing in the default frame settings (which are the ones used by the scene camera)

    upload_2020-7-27_16-34-9.png

    Best,
     
    fuzzy3d likes this.
  4. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    228
    Yes, this is editor... But how to turn raytracing on and off effectively by script- with button in real-time?
     
    me2539901lreplco and newguy123 like this.
  5. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    You can have multiple HDRP asset (one with and one without raytacing) and switch quality settings at runtime.

    Another idea would be to override the raytracing checkbox in raytracing in the custom frame settings of your camera at runtime with something like this

    Code (CSharp):
    1. //Getting components
    2. _cameraData = this.GetComponent<HDAdditionalCameraData>();
    3. _frameSettings = _cameraData.renderingPathCustomFrameSettings;
    4. _frameSettingsOverrideMask = _cameraData.renderingPathCustomFrameSettingsOverrideMask;
    5.    
    6. //Make sure Custom Frame Settings are enabled in the camera
    7. _cameraData.customRenderingSettings = true;
    8.    
    9. //Enabling RayTracing bit
    10. _frameSettingsOverrideMask.mask[(uint)FrameSettingsField.RayTracing] = true;
    11.    
    12. //Applying the frame setting mask back to the camera
    13. _cameraData.renderingPathCustomFrameSettingsOverrideMask = _frameSettingsOverrideMask;
    and then on the update you can change the framesettings with somehtine like this

    Code (CSharp):
    1. if(Input.GetKeyDown(KeyCode.R))
    2. {
    3.     //Basically toggle the raytracing on the camera
    4.     _frameSettings.SetEnabled(FrameSettingsField.RayTracing, !_frameSettings.IsEnabled(FrameSettingsField.RayTracing));
    5.     _cameraData.renderingPathCustomFrameSettings = _frameSettings;
    6. }
     
    Last edited: Sep 16, 2020
  6. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    228
    Many thanks, chap-unity!
     
  7. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,251
    Best thing I found (if you just want to edit/move things) is toggle the scene lighting button in scene view (because try path-tracing in scene view!!)
    Everything goes bright blue for a bit (what is that with blue materials these days?)
     
  8. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    760
    Bright blue material is simply shaders that are not compiled yet !