Extra: Using the stencil buffer effect
Hey all,

I thought I'd make a few examples of how you could use the shaders I've show in the latest tip
Here are the 2 shaders again, just to be sure:

The Mask Shader : Pastebin Link 

Toon Masked Object Shader : Pastebin Link

Containing Within Mask

A 3D card effect within a flat plane

Setup:
As shown in the tip
The card frame is a normal material. Within the "window" of the frame is a plane that has the Mask Shader with ID 1.
The cat, moon, and background all have the Toon Masked Object Shader with the same ID


Replacing 

Hide messages in a painting

Setup:
Two Planes with a slightly different picture on them.
One Plane is a normal material, the second has a Masked Object Shader with ID 1
The circle has the Mask Shader with ID 1, and a script attached that sets it's position from Mouse Input "Input.mousePosition" to "Camera.main.ScreenToWorldPos" 

Hiding Behind Mask

Reveal hidden areas with a special item

Setup:
The environment and weapon/sparkles are built out of normal materials. In front of the weapon is a cube with an edited version of the Masked Object Shader.

Instead of "Comp equal" in the stencil operation, it says "Comp notequal", so it is only shown when the mask is NOT over the object

Stencil {

Ref [_ID]

Comp notequal

}

The Mask Shader is not edited, and both still have ID set to 1.

Masking Particles

A portal to another level/world

Setup:
A particle system that is emitting meshes with a Mask Shader material.
In the same position as the particle system is an environment mesh with the Toon Masked Object Shader. Both shaders have ID 2

The glowing particles around the portal are that first particle system duplicated twice.
One of these duplicates has a Masked Shader with ID 1, the other is emitting a Particle Masked Object Shader , also with ID 1. These get rendered behind the portal

Hope you can find some use for the shaders :)

Become a patron to

139
Unlock 139 exclusive posts
Be part of the community
Connect via private message