Partial Texture Swapping in Real Time

Hey guys!

So I’m trying to figure out how to do this mechanic and if it’s even possible.

I know how to, or at least can figure out, how to swap textures or materials in real time from the script but the problem here is I don’t necessarily want to swap out the whole texture.

Basically what I have is a 2.5D side scrolling game. At some points the player can activate a large reticle that be overlain on the entire screen and will move with the mouse cursor. Inside this reticle, I want to switch the textures of the objects but I only want this to happen INSIDE the reticle. If an object is half in and half out of this reticle, it should have both the normal and the new texture on it. The reticle can be circular or rectangular.

Here is an example of what I’m looking for,

Without reticle

alt text

With reticle

alt text

There won’t be many objects within this reticle at any given time but it’s not a simple color swap as I have done in this example, it would be full textures.

So any ideas? Is this even possible? If so how would I go about doing it?

Appreciate the help.

One way is to create a circular mesh, and use a depth mask shader on it. Then have duplicates of everything (with normal and alternate materials), and another camera that renders the “alternate” world. Set the layer masks for the cameras so the each camera only renders the appropriate objects. You can have the alternate objects be children (without colliders, only renderers) of the normal objects so that it’s simple to keep everything in sync.

See the ScreenWipes script on the wiki (specifically the ShapeWipe function) for an example of this concept.