Magic Window Shader

Hello Guys.

I need a little bit help from you.
What I search for is a shader that changes a texture/ material depending on “through” what mesh you are looking.

I will try to explain:

[1]this mesh has 2 textures (or 2 materials) assigned it looks like this when the camera looks at it.
[2]this is the Magic window :slight_smile: a mesh with a transparent shader

now if you look through the Magic window [3] on a mesh with this special shader you see a different texture (or material)

hope you guys understand what I’m looking for
the question is - is there something like this out there? I’ve searched the whole asset store but couldn’t find it :frowning:
Or can I somehow fake this without coding (I’m an artist not a programmer… )

thank you in advanced

I fear you have to get your fingers dirty with some code to get this done. I’d do it this way:
The magic window material will have two passes:

  • the first one renders before any opaque objects and just marks itself to the stencil buffer, without writing to the color buffer.
  • the second pass simply renders the transparent tint you have there in the proper transparent queue

Now, all materials that should be changed by looking through it will have two passes as well:

  • the first one checks the stencil buffer for the value you set with the first material and renders itself when this condition passes. So it should describe how the model looks like when looked through the window
  • the second one renders when the stencil is not marked - that’s the material’s normal look.

I’m sure you can put this together. Look up stencil operations and render queues.

I know i will need unity pro for this need to wait a few days.
@Dolkar - just learning the basics of shader coding it is not as hard as I though. will post a solution when done

You don’t need unity pro for my approach :slight_smile: It should also be noticeably faster.