Hello!
I’m currently trying to implement a PVS-system based on pre-calculated visibility info. It works fairly well by setting the renderer for each invisible object to disabled when they are not visible from the current “zone”. My problem is, however, that when I enable shadows, I have not yet found a good way to let the shadowpass use different visibility info than the camera. This leads to shadows popping in and out depending on the current camera position.
Since I am well aware of my suckyness when it comes to problem explanation, I’ve attached two screenshots. In one of them, the PVS is disabled, and all shadows appear correct. The second screenshot is taken from the exact same position, only this time with PVS enabled. As you can see, the shadows outside the door differs in the two screenshots, since the shadowpass only considers objects visible from the camera position, while I would like it to consider objects visible from where the shadowmap is rendered.
My question boils down to this: what is the simplest way to control which objects get rendered into the shadowmap, while they may not be rendered in the main pass?
I am aware of the enable/disable shadow-casting flag, but I fail to see how I can use that as I may already have disabled the renderer for the particular object I need to be casting shadows. Is there any way I can disable/enable objects for rendering between the two passes?
Thanks,
-Trond
Just thought I’d add a couple more screenshots showing the scene from a different angle to better illustrate the problem.
-Trond
Really good work ToreTank, I like it and I have some questions because I would like to implement a PVS system to solve the visibility problems.
Did you use transform.renderer.enable=false; to disable the meshes? Did you solve the problem with shadows?
I really interested In this because we have a lot of problems with optimization and we thing that could be a good solution.
Thx
Hello!
I sort of put this one on hold and haven’t looked into it for some time, so I haven’t really resolved the issue.
I was using renderer.enabled, yes, if I’m not horribly mistaken. Regarding the shadow issue, I didn’t get it to work correctly using the built-in lighting - however, it should be quite possible to roll your own shadowing system using RenderTextures, replacement shaders and custom object shaders to do the shadow mapping. That’s going to involve a fair bit of work though, but I can’t think of a different way to handle it (if you really need real-time shadows).
The iPhone version uses a similar PVS system afaik, so let’s just hope it’s implemented in desktop Unity soon
Thanks for all. I know than it will be a PVS system in desktop Unity soon but I don’t know when soon will be and I need this.
In addition I’m in a University and if we implement our system we could do some variation with last technics.
There was no mention that it will be added to the Desktop version soon actually.
It was always mentioned that they will look to backport / implement a similar thing on the desktop but nothing more than that.
I doubt it will happen with Unity 2.x if there will be another 2.x release at all (2.6.x release(s) are known to happen to fix the issues with 2.6 naturally )