- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
shaderWriter · May 16, 2015 at 04:25 PM ·
c#reflectionprobes
Trouble dynamically updating reflection probe
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;
}
}
}
Comment
Answer by RyanFavale · Apr 27, 2017 at 09:11 PM
Just ran into this myself when disabling 1 probe but not the 2nd. Not sure yet whether it has to do with 2 probes conflicting on the is finished call. @shaderWriter
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
il2cpp generics and overloads 0 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Call c# script function from managed c# script in dll 1 Answer