Does anyone know of any clever ways for having a lens flare culled by normal render geometry rather than just collision? Perhaps a custom shader or something? I know a lot of other engines do it somehow. The reason I’m looking to do this is because I don’t want to author intricate collision for things way out of the players reach.
Usually it’s done by harware occlusion queries. For a high level description and some proposed integration suggestions, see:
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html
tl;dr summary:
To my knowledge unity has no interface to use hardware occlusion queries.
tl;dr description:
you submit basic geometry to the gpu which renders it against the z buffer and records the number of rejected pixels. The next frame the cpu can read this data back and you can use the information; traditionally this is culling geometry when it’s occluded by other things (eg, a room behind a closed door), but it’s also useful for effects like lens flare’s since you can figure out how much of your proxy area was visible or not.
So as I mentioned above, to my knowledge unity has no interface to use hardware occlusion queries, and unfortunately there’s no other fast way to get read-back on the cpu. There are alternatives involving manual cpu read-back, or gpu only depth test->write->vertex read, but these can be slow and/or a decent amount of effort to implement.
Ah, darn. I’m afraid I’m not up to those tasks. Well, I really appreciate your answer. Its good to know for certain. I guess I’ll stick to authoring collision all over the place.