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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Custom Volume Components & Parameters

Discussion in 'High Definition Render Pipeline' started by nehvaleem, Sep 24, 2022.

  1. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    246
    I am trying to wrap my head around custom VolumeComponents & VolumeParameters.

    Let's say that I want to create a VolumeComponent for my camera system and change fov for example.

    I'll create CameraVolumeComponent that will derive from VolumeComponent and declare FloatParameter for the fov. Now: where I should put the actual setting of the fov? Should it be inside the overridden Override method of the VolumeComponent? If so - how I should approach the blending of the values?

    I thought that I will simply create a custom VolumeParameter and put my code inside the Interp method but it is sealed, so this is obviously no go.

    Also - I know that VolumeProfile is SO-based, but it is a way to reference scene objects somehow?
    Lastly - is there a way to detect entering/exiting from the volume? I would like to trigger some callbacks when it happens.

    I will really appreciate some guidance, thanks!
     
  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    496
    I am just learning, so use at own risk!

    - My only experience with volumes is you store profiles in assets on disk, then blend between them. So no experience with creating your own components sorry. (Hmmm, https://github.com/Unity-Technologies/FontainebleauDemo did create a "wind" volume in Assets/Scripts/BasicWind, had some code there, in case it gives any hints).
    - I use Cinemachine Virtual Cameras - adjusting the focal length property there adjusts the main camera focal length and field of view together (might not be relevant to your case).
    - Have you looked at "Local Volumes" instead of "Global Volumes"? You can define a local region where the volume is in effect. There is blending etc when you are near the edge. So when you move the character into the local volume space, the volume for that space kicks in. I think there is box volume, sphere volume, etc for a few different shapes... (collider zones). See also
     
    Last edited: Sep 24, 2022
  3. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    246
    Thanks, but I know how volumes work in general. I'm all after creating custom VolumeComponents and utilizing them.

    Thanks to the discord support I now know that all I have to do is to read the current (already interpolated value) of the particular component parameter using VolumeStack which can be accessed through:
    HDCamera.GetOrCreate(Camera.main).volumeStack.GetComponent<CustomVolumeComponentType>()


    And it is working great, I'm already almost done with what I need atm.

    So now I just searching for answers for:
    1. I know that VolumeProfile is SO-based, but it is a way to reference scene objects somehow?
    2. Is there a way to detect entering/exiting from the volume? I would like to trigger some callbacks when it happens.