Shader "Custom/Mask"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_ColorStrength("Color Strength", Range(1,4)) = 1
[Space(10)]
_EmissionColor("Emission Color", Color) = (1,1,1,1)
_EmissionTex("Emission (RGB)", 2D) = "white"{}
_EmissionStrength("Emission Strength", Range(1,4)) = 1
[Space(10)]
_Transparency("Transparency", Range(0, 1)) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex, _EmissionTex;
struct Input
{
float2 uv_MainTex;
float2 uv_EmissionTex;
float3 worldPos;
};
fixed4 _Color, _EmissionColor;
half _ColorStrength, _EmissionStrength, _Transparency;
uniform float4 FILTERmask_Position;
uniform half FILTERmask_Radius;
uniform half FILTERmask_Softness;
void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
// Grayscale
half grayscale = (c.r + c.g + c.b) * .3;
fixed3 c_g = fixed3(grayscale,grayscale,grayscale);
// Emission
fixed4 e = tex2D(_EmissionTex, IN.uv_EmissionTex) * _EmissionColor * _EmissionStrength;
// Transparency
// Put Transparency here
half dist = distance(FILTERmask_Position, IN.worldPos);
half sum = saturate((dist - FILTERmask_Radius) / -FILTERmask_Softness);
fixed4 lerpColor = lerp(fixed4(c_g,1),c * _ColorStrength,sum);
fixed4 lerpEmission = lerp(fixed4(0, 0, 0, 0), e, sum);
o.Albedo = c.rgb/*lerpColor.rgb*/;
o.Emission = lerpEmission.rgb;
o.Alpha = c.a * _Transparency;
}
ENDCG
}
FallBack "Diffuse"
}
First time coding shader here. I've found a pretty good tutorial to follow to achieve most of above. What it does now is making a spherical area glow and colorize, but everything else gray: Simple. However, I wanted to make some change of my own from there and really got stuck.
What I wanted to do was replace the colorization with the spherical area to just make a transparent hole on this surface. Am I on the right track? Or am I not even using the right shader type?