Hi All,
I have a reflection probe set to custom and would like to update it at a specific time via script.
I have this code:
texture = new RenderTexture(1024, 1024, 16, RenderTextureFormat.ARGB32);
texture.isCubemap = true;
renderID = probe.RenderProbe(texture);
probe.customBakedTexture = texture;
However this gives a very blurred texture, also IsFinishedRendering never appears to return True
Here is a full code snippet:
using UnityEngine;
using System.Collections;
public class updateCubemapTest : MonoBehaviour {
public ReflectionProbe probe;
public RenderTexture texture;
int renderID = -1;
bool done = false;
// Use this for initialization
void Start () {
if (probe == null){
return;
}
probe.timeSlicingMode = UnityEngine.Rendering.ReflectionProbeTimeSlicingMode.AllFacesAtOnce;
texture = new RenderTexture(1024, 1024, 16, RenderTextureFormat.ARGB32);
texture.isCubemap = true;
renderID = probe.RenderProbe(texture);
}
// Update is called once per frame
void Update () {
if (texture == null){
return;
}
if (done){
return;
}
bool isDone = probe.IsFinishedRendering(renderID);
string message = string.Format("probe.IsFinishedRendering({0}) = {1}", renderID, isDone);
Debug.Log(message);
if (isDone){
probe.customBakedTexture = texture;
done = true;
}
}
}