Posts

Showing posts from April, 2019

Unity Shader: Spherical Mask

Image
I'm a big fan of Beyond Eyes game and the way the world takes form while the little girl walks around. Last time we looked at the dissolve effect this time we take a look at Spherical Mask effect. The two effects combined together will let us create a custom shader that emulates the Beyond Eyes effect. Let's begin! Spherical Mask The image above is pretty self explanatory, we have a player object that has a radius of action, every pixels inside its radius of action will be colored while the others stay in grayscale. Let's begin with adding two input propeties to our shader: 1 2 3 4 5 6 7 8 9 Properties { //...other shader properties //Spherical Mask properties _PlayerPosition( "Player Position" , Vector) = ( 0 , 0 , 0 , 0 ) _Radius( "Mask Radius" , Range( 0 , 100 )) = 0 _Softness( "Mask Softness" , Range( 0 , 100 )) = 0 } _PlayerPosition passes the player postion to the shader  _Radius is the player radius

Unity Shader: Dissolve Shader

Image
In this article I'd like to show you a quick and easy way to implement the dissolve effect. Mind you, the code is not optimized to make it easier (hopefully) to understand. Let's begin! The Dissolve Texture First of all we need a dissolve texture and we can generate it ourselves using Photoshop Cloud filter. Here's mine: The Shader Add a new Standard Surface Shader in Unity. Add two new input properties to our shader: 1 2 3 4 5 6 7 8 Properties { //...Other shader properties //Dissolve Shader Properties _DissolveTexture ( "Dissolve Texture" , 2D ) = "white" {} _Amount( "Dissolve Amount" , Range( 0 , 1 )) = 0 } _DissolveTexture is where we put our dissolve texture _Amount represents the progress of dissolving our object (0 = visible, 1 = disappeared) In the surf function is where the magic happens! We get the  dissolve_value by sampling the color of our _DissolveTexture using the