kode80 / kode80CloudsUnity3D

A realtime volumetric cloud rendering solution for Unity3D.
367 stars 64 forks source link

CPU & GC optimizations #9

Closed Chman closed 7 years ago

Chman commented 7 years ago

The FullScreenQuad class was generating garbage on every frame, it's now fixed.

More importantly, this PR optimizes material usage. Every time you do a material.SetXXX(string, value); it will internally compute a hash for the name and do a lookup. Considering the amount of uniforms sent on every frame in this asset... It can quickly become expensive on slower CPUs. So no need to do it on every frame, it should only be done once and reused :)

Every little bit helps... Uniforms should be tightly packed together (e.g. put 4 float in a float4) to optimize this even more but for now that'll do.

kode80 commented 7 years ago

Thanks, this is great stuff. I'll review and merge this week!

kode80 commented 7 years ago

Merged, big thanks for this!