Over the past couple days I've been putting together my portal shader. The idea behind this was to create a tunnel which opens up and seems to pass through anything behind it, which also allows stuff to pass into it and then not be visible when the portal closes.
Here what I ended up with for the main portal:
Obviously, it's got some work left to pretty it up a bit, but the main part of the shader is working.
For this post, i'm splitting the effect into 2 main parts, the portal shader, and the object function.
Portal Shader:
To achieve this effect I'm using 2 meshes, the tunnel, and a disc which is fitted to the opening of the tunnel.
In engine I put the 2 meshes into a blueprint with the disc aligned to the tunnel. I then set the disc to render to the custom depth buffer, while not being rendered in the main pass.
What this allows me to do is, in the tunnel shader, compare scene depth to the custom depth buffer, and use the output to drive an opacity value. In essence if scene depth is more than custom depth, then the tunnel will be visible.
With this set up the next problem was that if the portal goes through any geometry, that geometry is visible. I fixed this with a bit of a cheat, but it does the job. I just make a duplicate of any materials I need, and set them to transparent, with a lower sort order priority than the portal.
And boom, portal shader halfway there!
Now, onto allowing stuff to get in it.
No comments:
Post a Comment