How to create an x-ray effect similar to that of the built-in x-ray function?

So I’m trying to make some conjoined eyes with the Cycles render engine. Here’s how I’m trying to accomplish this task:

The eye is made up of two layers: the iris and the pupil. Here’s a better look at it:

So what I want is for the pupil to appear through the iris to give it some sense of depth to prevent it from looking too flat. Here’s what I want it to look like (edited image, not actual render):

The thing is, though, is that I want to create this without using extra render layers. That way it would be faster to render and easier to manage.

One method I thought of is to create a mix shader that has a transparent node put into it, and then put something in that would indicate where it is behind the model. Unfortunately I have no idea how to do this.

Another idea I thought of is that to have the pupil texture somehow be projected onto the iris texture, and have it change it’s position depending on the camera angle. But, once again, I have no idea how to do this.

Is there any known method to accomplish something like this?

Have your tried using the pupil texture where the ‘Pupil Detector 3000’ is? It might work if both objects have the same (or VERY similar) shape.

My eye models do have the exact same shape, but what do you mean by “using the pupil texture”? If you’re suggesting that I should just simply apply the “Image Texture” node, it’s not all that simple.

The reason for the extra plane behind the eye is so that the pupil will change it’s position depending on what angle the camera is relative to it. In other words, it’s so that I can make the eye look “3D” but without making it lose it’s 2D look. On the edited image, you can see that the pupil seems to be near the edge of the iris, creating a false sense of depth. That way, the eyes won’t look like they were just printed on.

I think I understand what you are after now. Sorry for the misdirected post. Here is what I got:



(forgive the awful render)
Here are the node setups:


The back plane


The front plane

It requires that you paint a texture for the transparency and a texture for the color behind the “eyeholes”

Hope this helps a bit more…