Notifying Unity about texture modifications

When you modify a Texture directly on the GPU side (eg. via Compute Shaders), Unity has no way of knowing that the texture has changed. This can break some things if you assign the texture as a density volume mask, a light cookie texture, etc.

I first stumbled upon Texture.imageContentsHash, but don’t actually use that - confusingly enough, it’s an editor-only property and doesn’t even exist in UnityEngine.dll in builds.

What you actually want is:

Increment the update counter.
Call this method when you update a Texture from the GPU side, or you want to explicitly increment the counter.

Simply call the method on the texture and - if you’re lucky - Unity will notice that the texture has changed.

// bump the texture version

texture illustration