Search Unity

Resolved Why do baked Reflection Probes capture scene different when using Lightmapping.BakeReflectionProbe?

Discussion in 'High Definition Render Pipeline' started by dgoyette, Apr 4, 2023.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'm trying to set up a simple script to automate the baking of reflection probes in my scene. I'm using
    Lightmapping.BakeReflectionProbe
    to perform the bake, but I'm finding that the resulting generated texture isn't the same as it is if I press the Bake button in the Reflection Probe's inspector.

    For example, here's the result of pressing Bake:

    upload_2023-4-4_16-27-11.png

    And here's the same probe after calling
    Lightmapping.BakeReflectionProbe
    :

    upload_2023-4-4_16-28-0.png

    It seems that the
    Lightmapping.BakeReflectionProbe
    version is pulling in a bunch of additional lighting that the "Bake" button version is not. Interestingly, it seems that the
    Lightmapping.BakeReflectionProbe
    is baking its own lighting into the cubemap. That is, if I disable the reflection probe before calling
    Lightmapping.BakeReflectionProbe
    , I get different results. But even disabling the probe before baking, the
    Lightmapping.BakeReflectionProbe
    version is picking up other specular reflections and lighting.

    Is there a different way to bake reflection probes programmatically that I should be using?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I found the answer. Instead of using
    Lightmapping.BakeReflectionProbe
    , I should be using
    LightmappingHDRP.BakeProbe
    . Using that approach, the result is the same as pressing Bake in the inspector.

    So I'm all set here. I guess the example code I was looking at for reference was for built-in, not HDRP.
     
    valarnur likes this.