Search Unity

Resolved How to update reflection probe's bakedTexture at runtime?

Discussion in 'VR' started by arielcorrea, Jun 18, 2022.

  1. arielcorrea

    arielcorrea

    Joined:
    Feb 21, 2019
    Posts:
    14
    Hello forum, so I have an app that has some sort of real time day cyle which I am building for the Quest 2. To achieve this, I am doing some simple texture blending and for my lightmaps, I decided to simply multiply all the materials color to a given color for that day cycle.

    The problem is how to update the reflection probe. I managed to make it work, but currently it is only working in the editor.

    Right now I managed to achieve what I want by using the ReflectionProbe.BlendCubemap method, pass my renderTexture and then assign it to the bakedTexture.

    Here is the result: https://drive.google.com/file/d/1B9EMQMjD9l1bdnX_twV9MoTZl5lgkjNf/view?usp=sharing

    So I am wondering, is that the right way to do it? What should I do to make it work on the build?

    Obs: I know there are some assets that do exactly that, I tried the MLS, but had some difficulties due to my project structure. It seems to have some problems with the way Unity arranges multi scenes.

    Edit: Since it is now working I will leave my solution here:

    Essentially I am blending the reflection probe's cubemap using a render texture.

    On Awake function I create a renderTexture at runtime:
    upload_2022-7-24_19-0-41.png

    And then this function updates the renderTexture based on a given float value:
    upload_2022-7-24_19-2-18.png
     

    Attached Files:

    Last edited: Jul 24, 2022
  2. arielcorrea

    arielcorrea

    Joined:
    Feb 21, 2019
    Posts:
    14
    So I figured out the problem. I created a blank URP project, brought my code to it and set all the VR stuff. It worked normally. Started checking setting by setting, realized that on Project Settings in the secion "Always included Shaders" I had only 2 on my project, while the URP blank project includes 10 by default. Anyways, basically you need to include these if you want to do Cubemaps blending:
    upload_2022-7-24_18-51-11.png
     
    Last edited: Jul 24, 2022
    glenneroo likes this.