-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added brush and implemented opacity size and hardness
- Loading branch information
Showing
6 changed files
with
156 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Shader "Unlit/BrushShader" | ||
{ | ||
Properties | ||
{ | ||
_MainTex("Texture", 2D) = "white" {} | ||
|
||
} | ||
SubShader | ||
{ | ||
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" } | ||
ZWrite Off | ||
Cull Off | ||
Blend SrcAlpha OneMinusSrcAlpha | ||
LOD 100 | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
float4 proj : TEXCOORD2; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float4 _MainTex_ST; | ||
sampler2D_float _CameraDepthTexture; | ||
float4 _Color; | ||
v2f vert(appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.proj = ComputeScreenPos(o.vertex); | ||
COMPUTE_EYEDEPTH(o.proj.z); | ||
//Use this for linear one | ||
//o.proj.z = COMPUTE_DEPTH_01; | ||
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | ||
|
||
return o; | ||
} | ||
|
||
fixed4 frag(v2f i) : SV_Target | ||
{ | ||
// sample the texture | ||
fixed4 col = tex2D(_MainTex, i.uv); | ||
float depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.proj.xy / i.proj.w)); | ||
|
||
float a = saturate(depth - i.proj.z); | ||
a = smoothstep(0., 0.2, a); | ||
a = 1. - a; | ||
a = pow(a, 10.); | ||
col.a *= a; | ||
return col* _Color; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters