Daylight Water draw calls are based on...

I just did a bunch of testing with Daylight Water (which I think is a Pro Asset). My draw calls were really high in a couple scenes, and I found the following things do not lower the draw calls:

  • the Scale of the Daylight Water
  • any of the variables in the Water script

What affects the number of draw calls – and hence the frames-per-second – is how many things the water reflects and refracts.

Note #1: technically, the “variables in the Water script” could affect the draw calls, if you tell the water not to reflect / refract a bunch of game objects. But then the water looks stupid.

Note #2: all this information might be in the documentation somewhere but I didn’t go looking for it. I just experimented.

the water itself has exactly 1 drawcall

But what people tend to forget:

  1. every reflected object is basically drawn once again, so the more objects you have in reflection, the worse the drawcall impact.

  2. the same goes for refraction as the whole stuff refracted first needs to be rendered into the RT

Thanks dreamora. Good explanation!

And if you have both reflection and refraction, then you have 4X the draw calls you would have without them.

–Eric

One thing that’s possible to do (and what is done by slightly changed water script in Island Demo example): before rendering water reflection/refraction, turn some options down; after it’s done, restore it back.

So in Island demo, it does those things (IIRC):

  • Reduce tree drawing distance
  • Reduce terrain LOD
  • Turn off grass completely (maybe only for refractions?)
  • Maybe even reduce camera’s far clip plane

You could also turn off some layers; e.g. if all your small boxes are in some layer, maybe it’s not worth rendering it for reflection.

Thanks Aras. I came up with something similar yesterday: enemies farther than X from the camera are on a layer that doesn’t reflect/refract. Once the camera is close enough, they get switched to the Default layer (which is reflected/refracted).

I’ll add in those other things too!

Actually, no need to juggle layers. Since Unity 2.6 you can setup per-layer far culling distances on a camera: Unity - Scripting API: Camera.layerCullDistances

Doing that might make sense even for a main camera. E.g. put all very small objects into some layer and make them disappear much earlier than the far plane.

Thanks Aras, but I already programmed the layer-switching script. (I’m mainly a programmer.) It’s pretty brief, and works great!

Also I don’t want to have to set the layer of 50 enemies at design time. That’s a pain. Just attach one script to their prefab and it does the work for me!

Plus all the enemies (about 50) are on the Default layer. If I change the culling stuff for the Default layer, that’ll affect almost everything in the scene. if I change all 50 enemies to a different layer … well, that’s 50 enemies I’d have to change! Script seems simplest.

Maybe I am reading it wrong but it seems to me that having all Enemies, for instance, default to an Enemies layer and it would be as simple as using the code at the Aras provided to prevent them from being rendered after a certain distance and once they hit that barrier then they would. Of course I might be looking at this in a more simplistic way then what you are trying to accomplish.

I have been doing something similar with layers but have started combing through the reference manuals and user guides again because its become apparent from reading these threads there are a lot of things I am making a lot harder than they need to be.

EDIT: That is if your 50 enemies are all based on the same prefab, if not then yeah I guess you would need to change each individual prefab to a different layer but shouldn’t have to do each individual enemy in the scene.

@Guru I’m starting to think the idea of putting all enemies on one layer is good. I’d put all health pickups and other game doodads on that same layer. Unfortunately, we didn’t start designing the game that way, so there’s other stuff tied to the layers that I don’t want to have to “untie”, if you see what I mean. Probably on the next game! (Especially now that I know about culling masks and water reflectivity and stuff!)