Applying shader to particular tiles

Suppose I have this scene:

I have made a water distortion shader that I want to be applied to the water tiles which will distort everything beneath it. How would the shader be able to differentiate between just tiles and then water tiles? Or maybe tiles isn’t the best way to do it, perhaps particular colour or alpha values? The camera can move and there could be multiple bodies of water too. How should I go about doing this?

Assuming that your water tiles are always 100% water, as seems to be the case, this should be pretty straight forward, no need for per-pixel masking:

1.) Draw all background tiles without water to a render target.

2.) Set a new render target of the same size.

3.) Copy the entire background render target into the new render target by rendering one full screen sprite.

4.) Render only the water tiles using the water shader. The background render target needs to be passed to the water shader as a shader parameter.

1 Like

Thank you, this works a charm!