Skip to content

Commit

Permalink
uploaded shaders from past lessons
Browse files Browse the repository at this point in the history
  • Loading branch information
Xibanya authored Mar 30, 2023
1 parent 948e761 commit f3b0024
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 22 deletions.
6 changes: 5 additions & 1 deletion Assets/Shaders/Unlit/ColorMaskBlend.shader
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//This shader is tutorialized in Part 29: Smooth Blending with Sine
//This shader is tutorialized in Shaders For People Who Don't Know How To
// Shader Part 29: Smooth Blending with Sine
//https://www.patreon.com/posts/shaders-for-who-35129311
// This code is by Xibanya and shared under an Attribution 4.0 International
// (CC BY 4.0) license
// https://creativecommons.org/licenses/by/4.0/
Shader "Xibanya/Unlit/ColorMaskBlend"
{
Properties
Expand Down
68 changes: 68 additions & 0 deletions Assets/Shaders/Unlit/Rotation2D.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Shaders For People Who Don't Know How To Shader Part 44: 2D rotation
// https://www.patreon.com/posts/shader-tutorial-73605548
// this code is shared under Attribution 4.0 International (CC BY 4.0) license
// https://creativecommons.org/licenses/by/4.0/
Shader "Xibanya/Unlit/Rotation2D"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Rotation ("Rotation", float) = 0
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"PreviewType" = "Plane"
}
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Rotation;

float2 Rotate2D(float2 uv, float angle)
{
float2x2 rotationMatrix = float2x2(
cos(angle), -sin(angle),
sin(angle), cos(angle)
);
return mul(uv, rotationMatrix);
}

v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
float2 uv = v.uv - 0.5;
uv = Rotate2D(uv, radians(_Rotation));
uv += 0.5;
o.uv = TRANSFORM_TEX(uv, _MainTex);
return o;
}

fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
return col;
}
ENDCG
}
}
}
47 changes: 26 additions & 21 deletions Assets/Shaders/Unlit/SpriteColorMask.shader
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
Shader "Xibanya/Unlit/SpriteColorMask"
// Shaders For People Who Don't Know How To Shader Part 15: Sprites
// https://www.patreon.com/posts/shaders-for-who-29239797
// Code shared under Attribution 4.0 International (CC BY 4.0) license
// https://creativecommons.org/licenses/by/4.0/
Shader "Xibanya/Unlit/SpriteColorMask"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "transparent" {}
[NoScaleOffset] _Mask("Color Mask", 2D) = "transparent" {}
_R("Red Channel Color", Color) = (1,1,1,1)
_G("Green Channel Color", Color) = (1,1,1,1)
_B("Blue Channel Color", Color) = (1,1,1,1)
_A("Alpha Color", Color) = (1,1,1,1)
[Enum(Off,0,Front,1,Back,2)] _Cull("Cull", float) = 2
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "transparent" {}
[NoScaleOffset] _Mask ("Color Mask", 2D) = "transparent" {}
_R ("Red Channel Color", Color) = (1,1,1,1)
_G ("Green Channel Color", Color) = (1,1,1,1)
_B ("Blue Channel Color", Color) = (1,1,1,1)
_A ("Alpha Color", Color) = (1,1,1,1)
[Enum(Off,0,Front,1,Back,2)]
_Cull ("Cull", float) = 2
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
"CanUseSpriteAtlas" = "True"
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
"CanUseSpriteAtlas" = "True"
}
Cull[_Cull]
ZTest Off
Expand Down Expand Up @@ -59,11 +64,11 @@
return o;
}

sampler2D _Mask;
half4 _R;
half4 _G;
half4 _B;
half4 _A;
sampler2D _Mask;
half4 _R;
half4 _G;
half4 _B;
half4 _A;

half4 frag (v2f i) : SV_Target
{
Expand All @@ -79,4 +84,4 @@
ENDCG
}
}
}
}

0 comments on commit f3b0024

Please sign in to comment.