Hello!
I’m having a little problem with the built in OC in Unity. Well as I understand it should render only the visible meshes, but in my case it renders all the meshes that are inthe view frustum. Well not exactly all, but most of them. The Thing gets confusing to me because there is no logic.
My example:
road with elevations (seems to work fine)
ground terrain meshes ( always visible in view frustum, even when its behind meshes)
custom shadow casting transparency shadered meshes ( the same as above, always in view frustum, even when behind meshes)
So would someone explain me why this is happening? Because I need to get OC working, the models are eating up alot of framerate, because the track is huge.
In order for OC to work,
u need to plan your scene very well and almost everything are an object of its own.
If you have one unity terrain on the whole scene, then the terrain will not be occluded since is one piece.
For the road, is best to cut into several pieces that can be joint later on scene building.
As for Transparency, not sure what the problem…
the only I can say, is that transparent object cannot be occluder.
You might wan to try make a new scene and try out OC with a few Cube and Plane to grab how’s the OC really work.
well the thing is, that the trees and roads are splited apart, the track has about 6000+ seprated objects.
As for transparencey I guess thats the case, OC cant recognice transparency, and that is a big issue in My view.
Tho there are those portals also, maybe they are here to fix this sort of problems?
yeah every single object is static, I did a research before using OC and everything should be as required, but probably it’s because the transparency shader
The transparency shader would cause objects to be occluded when they’re actually still visible, not the other way around.
Can you give any more detailed information? How are you setting up the Occlusion Areas? Are you changing any of the default settings for the OC bake? If you try a test OC scene with just cubes or something are you able to get the expected results?
The more information you provide the quicker we can figure out what the problem might be.
Well, the shader may be an issue because its a custom one, a older method for semi transparent areas, and a cutoff falback to cast shadows.
The scene itself, uhm I selected all the child objects in my main track object and simply applied the occlsion culling to them. Baked with deffault settings to see what happens. There are also some strange flickering of objects that are IN view frustum, wich is not right but maybe this is up to the settings?
Let me provide you a image of my critical sittuation:
tha actual ingame, as you can see the fps is quite critical for such a simple section, just a basic corner with some lowpoly foliage,
you can see the occlusion “grid” ( not sure if its the correct use of it, im not using occlusion areas)
now we see the problem, there is stuff behind the foliage, mostly the foliage itself, but this causes a massively low framerate, because practically the whole track is visible.
If that would help I could send you a PM with the shader code?
Also If neded I could attach a link to build, so you can see what sort of flickering I mean (sometimes practically the whole screen goes missing).
And heres a question, if i change the shader to diffuse, nothing changes, so do I have to bake again to see the changes take effect?
Ok, first thing to do is to create a proper Occlusion Area for the scene. From the looks of the second screenshot you have a ton of cells that the camera will never enter. It looks like this level is flat so you could make an Occlusion Area that is one cell high and covers the entire level. Just make sure the Occlusion Are encompasses the trees. The cell size can also be fairly large.
The shader doesn’t matter as only geometry data is taken into account when computing the solution. And yes, you have to re-bake whenever you make changes to the scene (moving/adding/deleting objects etc). But if you make an Occlusion Area that is only one cell high then baking for this level should be fast.
Ok, you’re sure the cells are encompassing the level geometry (I’m sure they are, just hard to tell from that angle). Those cells are too big, sorry, that’s my fault. Make it so you have 2 to 3 cells at that height.
Uh’m this is abit confusing because now it looks about the same as on earlyer posted image
Take a look:
About the Occlusion area, It doesnt seem to take any effect, I still had to select all the mesh renderers seprately and then i have to set “Ocludder Static” and “Ocludee Static” toggles in “object tab” and now I can bake, otherwise I get this error message as i posted in my previus post.
Yeah, but the one cell height was a stupid mistake on my part… if the cell height goes over the trees then that would mean every cell would be able to see every other cell. If you made the Occlusion Area lower than the tops of the trees you could probably get away with a one cell height, but 2 is probably better.
And as far as having to set every mesh as Occluder and Ocludee that’s the way it’s supposed to work.
So if you bake this what happens now?
If you’re still having trouble getting this to work I’m always open to having a look at the project myself if you have it on a repository somewhere. Some people don’t like to do this however and that’s understandable depending on whether it’s client work or not.
I’m baking the scene right now and wil ltell you what happens when its done. About the project, I cant send you the full project, and its about 10 gigs anyway at the moment with all the media. Tho If I cant get around with this problem anyway, I could maybe use the exact same media and make an example roject just to show the problem so you could investigate it.
Practically the same results, the problem is still there. Tho viewing the view lines, I see that they ignore trees, now I’m more starting to believe that its some sort of an issue of my shader, let me try to bake it with diffuse shader adn see if something changes…
switched to diffuse shader and Still get the problem, The trees have both sides modeled, actually they are 3 poly trees, not regular 2 cross trees. But In any case shader change didnt work, so there msut be something that I’m missing…
What are OC areas used for exactly and portals?