- Home /
Light culling using OnPreRender and OnPostRender after updating to 4.3
Hey everyone, I ran into a strange problem today after updating to Unity 4.3.
I've been using a simple script to hide certain lights from a secondary camera using OnPreRender and OnPostRender:
function OnPreRender () { var objects = GameObject.FindWithTag("InvisibleToGhostCamera"); objects.light.enabled = false; }
function OnPostRender () {
var objects = GameObject.FindWithTag("InvisibleToGhostCamera");
objects.light.enabled = true;
}</pre>
This code was serving me perfectly well and did exactly what I expected it to, up until I updated to 4.3.
With the code unchanged, the lights I'm trying to hide simply stay visible. If I comment out the OnPostRender part, it quite happily turns the light off (for all cameras, of course).
Any ideas on what went wrong? Is it a bug, did something change, is there a better solution anyway? Any help would be greatly appreciated as this problem is really starting to irritate me. =P
I have the same problem - going to revert back to 4.2.2 until this is fixed :(
Answer by MylesLambert · Dec 18, 2013 at 12:23 PM
It's a confirmed bug, http://issuetracker.unity3d.com/issues/onprerender-and-onpostrender-are-reversed.
Answer by Barachiel · Dec 18, 2013 at 04:11 PM
After stumbling upon it by accident, using OnPreCull and OnPostRender does more or less the same job, for those of you needing a way to do this. =)
Your answer
Follow this Question
Related Questions
I need help with directional light 1 Answer
Grafic problem with planes: ugly stripes 1 Answer
Indoor Lighting Scene - Baking? Realtime? 0 Answers
Shadows are too dark without ambient light 0 Answers
Realtime lighting with generated mesh causes light bleed at seams / edges (minecraft clone) 2 Answers