Closed leonidasos closed 6 years ago
Yeah, .Version is a problem already mentioned in Forum thread and totally my fault. It will be fixed in the next iteration.
Setting the TotalDisplacementMap is necessary for correct shader behaviour. It's pretty costly as it needs to update the displacement map for further processing.
My fault. Maybe I did not precise myself enough. It's not about 'TotalDisplacementMap'. Below example works for me. WaterCamera is known because we have all information about current Camera and attached WaterCamera component. Why do we have to check if it's Camera.main ? We can have a different cameras. The most cost is Camera.main and it's very slow in Unity.
if (waterCamera.MainWater == _Water) { //&& Camera.main == camera) {
Shader.SetGlobalTexture(_TotalDisplacementMapId, overlays.TotalDisplacementMap);
}
@leonidasos
I guess that this check was there to ensure that the texture will be set to the shader only one per frame (it's not really what you call a good solution, i know). Your fix to just skip the check should be fine in that case.
I've fixed both this issues and there will be available in the next release.
I recommend to change two trivial changes which have huge performance impact.
1) Do not use regexp in OnPreCull() method in WaterCamera class. Why do we need to call for version in PreCull ? [Time ms] is very slow here.
VersionCompatibility.Version >= 560
Solution: I moved it to Awake()
2) Another thing is DynamicWater class
Do we really need this here? Camera.main is always very slow and calling it every frame kill performance. Solution: Remove it?
uws version: 2.0.0b3