Initial Commit

This commit is contained in:
Simeon Radivoev 2022-02-12 12:53:50 +02:00
commit ee5c2f922d
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
2255 changed files with 547750 additions and 0 deletions

BIN
Assets/Plugins/Light2D/Resources/DefaultLight.psd (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 0846a06dcf035814d9cee71f4ba273f9
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 16
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 0
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 2f3e08f3d4226f64c9158182b8ae6ba2
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag: Light
pSDRemoveMatte: 1
pSDShowRemoveMatteOption: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,95 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &178616
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 478616}
- component: {fileID: 2078616}
- component: {fileID: 11470202}
m_Layer: 0
m_Name: Lighting Camera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &478616
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 178616}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &2078616
Camera:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 178616}
m_Enabled: 0
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0
far clip plane: 1000
field of view: 90
orthographic: 1
orthographic size: 13
m_Depth: -2
m_CullingMask:
serializedVersion: 2
m_Bits: 0
m_RenderingPath: 1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!114 &11470202
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 178616}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6a84973fb2c2f0449bd5d1b1fbb5b86d, type: 3}
m_Name:
m_EditorClassIdentifier:
AmbientLightComputeMaterial: {fileID: 2100000, guid: 0d2e0bb3755347a42ba8fe781dcfa6f1,
type: 2}
LightOverlayMaterial: {fileID: 2100000, guid: 357b085471a3b6b4aace8aa4cc99238a,
type: 2}
BlurMaterial: {fileID: 2100000, guid: a359593f98c7f7740b07a09ac6d11e43, type: 2}
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 178616}
m_IsPrefabParent: 1

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 1edb62a71a37ab14183c75085a46a344
NativeFormatImporter:
userData:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f7c025ce67c2ee418af04fcf0d440d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,53 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Light2D/Internal/Alpha Replace" {
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
LOD 100
Cull Off
ZWrite Off
Lighting Off
Blend DstAlpha Zero
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 1bb1c98cd3e51d048abab0182e0b7698
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,95 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
That shader is used to compute iterative ambient lighting.
Similiar to FastBlur shader.
*/
Shader "Light2D/Ambient Light Computer" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 1.5
_ObstacleAdd ("Obstacle add", Float) = 0.1
_EmissionColorMul ("Emission color mul", Float) = 0.1
_SamplingDist ("Average sampling distance", Float) = 0.01
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex; // previous iterative ambient light texture
sampler2D _ObstacleTex; // light obstacles texture
sampler2D _LightSourcesTex; // light sources texture
half _PixelsPerBlock;
half2 _Shift;
half _ObstacleMul;
half _EmissionColorMul;
half _SamplingDist;
half _ObstacleAdd;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
return o;
}
half4 frag (v2f i) : COLOR
{
const half addMul = 0.25;
half4 emission = tex2D(_LightSourcesTex, i.texcoord);
half4 obstacle = tex2D(_ObstacleTex, i.texcoord);
obstacle = saturate(((1 - obstacle)*obstacle.a*_ObstacleMul + _ObstacleAdd));
half2 uv = i.texcoord + _Shift;
half4 oldLight = tex2D(_MainTex, uv);
// computing average value of near pixels
half4 maxLight = tex2D(_MainTex, uv + half2(_SamplingDist, 0));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(-_SamplingDist, 0)));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(0, -_SamplingDist)));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(0, _SamplingDist)));
half dist45 = _SamplingDist*0.707;
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(dist45, dist45)));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(dist45, -dist45)));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(-dist45, dist45)));
maxLight = max(maxLight, tex2D(_MainTex, uv + half2(-dist45, -dist45)));
emission.rgb *= emission.a*_EmissionColorMul;
half4 col = (maxLight + emission)*(half4(1,1,1,1) - obstacle);
return lerp(oldLight, col, 0.2);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: e3c01cd61ef58b144be454935b099194
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,81 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
Fast, low quality blur.
*/
Shader "Light2D/Fast Blur" {
Properties {
_Distance ("Distance", Float) = 4 // blur distance in pixels
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
//Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
half2 dist : TEXCOORD1;
};
uniform sampler2D _MainTex;
uniform half _Distance;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
half2 dist = _Distance*(1.0/_ScreenParams.xy);
o.dist = half2(dist.x, dist.y*0.707);
return o;
}
half4 frag (v2f i) : COLOR
{
half2 dists[8] =
{
half2(i.dist.x, 0), half2(-i.dist.x, 0), half2(0, i.dist.x), half2(0, -i.dist.x),
half2(i.dist.y, i.dist.y), half2(i.dist.y, -i.dist.y),
half2(-i.dist.y, i.dist.y), half2(-i.dist.y, -i.dist.y)
};
half4 sum = 0;
sum += tex2D(_MainTex, i.texcoord);
sum += tex2D(_MainTex, i.texcoord + dists[0]);
sum += tex2D(_MainTex, i.texcoord + dists[1]);
sum += tex2D(_MainTex, i.texcoord + dists[2]);
sum += tex2D(_MainTex, i.texcoord + dists[3]);
sum += tex2D(_MainTex, i.texcoord + dists[4]);
sum += tex2D(_MainTex, i.texcoord + dists[5]);
sum += tex2D(_MainTex, i.texcoord + dists[6]);
sum += tex2D(_MainTex, i.texcoord + dists[7]);
half4 tex = sum/9.0;
return tex;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 7a07d34125fdd2b439503718458f0894
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,78 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
This is simplest and fastest light shader without path tracking.
It requires no aditional data to work so it could be used with Particle System.
*/
Shader "Light2D/Light 1 Point" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 6
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f {
float4 vertex : SV_POSITION;
half4 texcoord : TEXCOORD0;
half4 scrPos : TEXCOORD1;
fixed4 color : COLOR0;
};
uniform sampler2D _ObstacleTex;
uniform sampler2D _MainTex;
uniform half _ObstacleMul;
uniform half _EmissionColorMul;
uniform float2 _ExtendedToSmallTextureScale;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.scrPos = ComputeScreenPos(o.vertex);
o.scrPos = half4((o.scrPos.xy - 0.5)*_ExtendedToSmallTextureScale + 0.5, o.scrPos.zw);
o.color = v.color;
return o;
}
half4 frag (v2f i) : COLOR
{
half2 thisPos = (i.scrPos.xy/i.scrPos.w);
half m = _ObstacleMul;
half4 tex = tex2D(_MainTex, i.texcoord.xy);
half4 col = i.color*tex*tex.a*i.color.a;
half4 obstacle = tex2D(_ObstacleTex, thisPos);
col *= saturate(1 - (1 - obstacle)*obstacle.a*m);
col.rgb *= _EmissionColorMul;
return col;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f2794556b1e93454bb371b8a718bc78b
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 20 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 20 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 20 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 1 Point"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 9f4a2ad6220aedf47a83280c2e1932e7
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 30 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 30 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 30 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 20 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f90422fc704c9ac47b22ad527e0151eb
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 40 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 40 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 40 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 30 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 47f04ff6c4cd6184e82b0d0902c007db
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 50 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 50 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 50 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 30 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 815936569415cfd459ace4f9e2026627
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 60 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 60 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 60 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 30 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 9423e206b9b6f5f45b0eeb0790bba270
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 70 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 70 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 70 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 30 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: c248f902c930201439651266882a2150
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 80 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 80 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 80 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "Assets/Light2D/Resources/Shaders/LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 40 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 9a981bc67d3aff14ea6d31cdfcc7e321
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,16 @@
/*
Deprecated shader. Will fallback to "Light 20 Points".
*/
Shader "Light2D/Light 8 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
Fallback "Light2D/Light 20 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 855974e4ec7380c468d9ef075b0c1134
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,40 @@
/*
Light shader with 90 path tracking steps.
Code contained in LightBase.cginc, only path tracking samples count is defined here.
*/
Shader "Light2D/Light 90 Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#define PATH_TRACKING_SAMPLES 90 // count of path tracking steps
#pragma target 3.0
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
#include "LightBase.cginc" // all code is here
#pragma vertex light2d_fixed_vert
#pragma fragment light2_fixed_frag
ENDCG
}
}
Fallback "Light2D/Light 40 Points"
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 3a65b5d7f8a65c346bb3f168c0c4a914
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,87 @@
/*
This is most expensive light shader with variable count of path tracking steps.
That shader could be used only on desktop / consoles due to poor performance and required features.
*/
Shader "Light2D/Light Auto Points" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_ObstacleMul ("Obstacle Mul", Float) = 500
_EmissionColorMul ("Emission color mul", Float) = 1
_StepCountMul ("Raytracking point count multiplier", Float) = 2
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma target 3.0 // replace with 4.0 if you see glitches with big _StepCountMul or texture resolution.
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#pragma glsl_no_auto_normalization
#pragma glsl
#include "UnityCG.cginc"
#include "LightBase.cginc"
#pragma vertex light2d_fixed_vert
#pragma fragment frag
uniform half _StepCountMul;
half4 frag (light2d_fixed_v2f i) : COLOR
{
half4 tex = tex2D(_MainTex, i.texcoord);
#ifdef PERSPECTIVE_CAMERA
half4 vPos = ComputeScreenPos(i.projVertex);
half2 thisPos = (vPos.xy/vPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
half4 cPos = ComputeScreenPos(mul(UNITY_MATRIX_VP, float4(i.texcoord1, 0, 1)));
half2 centerPos = (cPos.xy/cPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
#ifdef UNITY_HALF_TEXEL_OFFSET
thisPos += _PosOffset;
centerPos += _PosOffset;
#endif
#else
half2 thisPos = i.thisPos;
half2 centerPos = i.centerPos;
#endif
half pixelSize = 1.0/_ScreenParams.y;
half len = length((thisPos - centerPos)*i.aspect);
int steps = round(_StepCountMul * len / pixelSize);
half sub = 1.0/steps;
half m = _ObstacleMul*sub*len;
half4 col = i.color*tex*tex.a*i.color.a;
half pos = 0;
for(half i = 0; i < steps; i++)
{
pos += sub;
half4 obstacle = tex2Dlod(_ObstacleTex, half4(lerp(centerPos, thisPos, pos), 0, 0));
col *= saturate(1 - (1 - obstacle)*obstacle.a*m);
}
col.rgb *= _EmissionColorMul;
return col;
}
ENDCG
}
}
Fallback "Light2D/Light 80 Points"
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2412ddee9dd4ca048af34e5f28a6acbf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,113 @@
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
Base code for standard light shaders.
Light is computed by path tracking with fixed number of steps (PATH_TRACKING_SAMPLES).
*/
#ifndef LIGHT_BASE_INCLUDED
#define LIGHT_BASE_INCLUDED
#pragma glsl_no_auto_normalization
struct light2d_fixed_data_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR0;
float2 texcoord1 : TEXCOORD1;
};
struct light2d_fixed_v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
half4 color : COLOR0;
#ifdef PERSPECTIVE_CAMERA
half2 texcoord1 : TEXCOORD1;
float4 projVertex : COLOR1;
float zDistance : TEXCOORD2;
#else
half2 thisPos : TEXCOORD2;
half2 centerPos : TEXCOORD1;
#endif
half2 aspect : TEXCOORD3;
};
uniform sampler2D _ObstacleTex;
uniform sampler2D _MainTex;
uniform half _ObstacleMul;
uniform half _EmissionColorMul;
uniform float2 _ExtendedToSmallTextureScale;
#ifdef UNITY_HALF_TEXEL_OFFSET
uniform half2 _PosOffset;
#endif
light2d_fixed_v2f light2d_fixed_vert (light2d_fixed_data_t v)
{
light2d_fixed_v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
#ifdef PERSPECTIVE_CAMERA
o.texcoord1 = v.texcoord1;
o.projVertex = o.vertex;
o.zDistance = mul(unity_ObjectToWorld, v.vertex).z;
#else
float4 vPos = ComputeScreenPos(o.vertex);
o.thisPos = (vPos.xy/vPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
float4 cPos = ComputeScreenPos(mul(UNITY_MATRIX_VP, float4(v.texcoord1, 0, 1)));
o.centerPos = (cPos.xy/cPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
#ifdef UNITY_HALF_TEXEL_OFFSET
o.thisPos += _PosOffset;
o.centerPos += _PosOffset;
#endif
#endif
o.color = v.color;
o.aspect = half2(_ScreenParams.x/_ScreenParams.y, 1);
return o;
}
half4 light2_fixed_frag (light2d_fixed_v2f i) : COLOR
{
half4 tex = tex2D(_MainTex, i.texcoord);
#ifdef PERSPECTIVE_CAMERA
half4 vPos = ComputeScreenPos(i.projVertex);
half2 thisPos = (vPos.xy/vPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
half4 cPos = ComputeScreenPos(mul(UNITY_MATRIX_VP, float4(i.texcoord1, i.zDistance, 1)));
half2 centerPos = (cPos.xy/cPos.w - 0.5)*_ExtendedToSmallTextureScale + 0.5;
#ifdef UNITY_HALF_TEXEL_OFFSET
thisPos += _PosOffset;
centerPos += _PosOffset;
#endif
#else
half2 thisPos = i.thisPos;
half2 centerPos = i.centerPos;
#endif
half sub = 1.0/PATH_TRACKING_SAMPLES;
half len = length((thisPos - centerPos)*i.aspect);
half m = _ObstacleMul*sub*len;
half4 col = i.color*tex*tex.a*i.color.a;
half pos = 0;
for(int i = 0; i < PATH_TRACKING_SAMPLES; i++)
{
pos += sub;
half4 obstacle = tex2D(_ObstacleTex, lerp(centerPos, thisPos, pos));
col *= saturate(1 - (1 - obstacle)*obstacle.a*m);
}
col.rgb *= _EmissionColorMul;
return col;//half4(half3((thisPos - centerPos).x*20), 1);//tex2D(_ObstacleTex, thisPos);
}
#endif

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 96959c36c8be1834a92f359610cce597
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,49 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Light2D/Internal/Light Blender" {
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 5edc16468ed7a9d499760f70e80b23fd
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,41 @@
Shader "Light2D/Internal/LightBlockerReplacementShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "LightBlocker" }
Pass
{
Name "LightBlock"
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha
CGPROGRAM
#pragma vertex SpriteVert
#pragma fragment SpriteFragCustom
#pragma target 2.0
#pragma multi_compile_instancing
#pragma multi_compile _ PIXELSNAP_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
#include "UnitySprites.cginc"
half4 _LightBlockColor;
half _TextureWeight;
fixed4 SpriteFragCustom(v2f IN) : SV_Target
{
fixed4 c = lerp(1,SpriteFrag(IN),_TextureWeight);
c *= _LightBlockColor;
return c;
}
ENDCG
}
}
Fallback Off
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4300beb83de7e5047b69da730a1d787c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,72 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
This is simplest and fastest light shader without path tracking.
It's works like "Light 1 Point", but ignores obstacles at all.
It requires no aditional data to work so it could be used with Particle System.
*/
Shader "Light2D/Light Ignoring Obstacles" {
Properties {
_MainTex ("Light texture", 2D) = "white" {}
_EmissionColorMul ("Emission color mul", Float) = 1
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
Blend OneMinusDstColor One
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile ORTHOGRAPHIC_CAMERA PERSPECTIVE_CAMERA
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
float4 scrPos : TEXCOORD2;
};
sampler2D _ObstacleTex;
sampler2D _MainTex;
half _EmissionColorMul;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.scrPos = ComputeScreenPos(o.vertex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 tex = tex2D(_MainTex, i.texcoord);
fixed4 col = i.color*tex*tex.a*i.color.a;
col.rgb *= _EmissionColorMul;
return col;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 67bcc3638c6972d4baa0c90aa6b31e17
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,92 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
That shader is used to merge light sources, abmient light and game textures into one.
*/
Shader "Light2D/Light Overlay" {
Properties {
_GameTex ("Game", 2D) = "white" {}
_AmbientLightTex ("Ambient Light", 2D) = "black" {}
_LightSourcesTex ("Light Sources", 2D) = "black" {}
_LightSourcesMul ("Light Sources Multiplier", Float) = 1
_LightMul ("Resulting Light Multiplier", Float) = 2
_AdditiveLightPow ("Bloom Pow. Zero to turn off bloom.", Float) = 10
_AdditiveLightAdd ("Bloom Add", Float) = 0.2
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
//Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY HDR
#pragma multi_compile BLOOM_ON BLOOM_OFF
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoordGame : TEXCOORD0;
half2 texcoordLight : TEXCOORD1;
half2 texcoordAmbient : TEXCOORD2;
};
uniform sampler2D _MainTex;
uniform sampler2D _GameTex;
uniform half4 _GameTex_TexelSize;
uniform sampler2D _AmbientLightTex;
uniform sampler2D _LightSourcesTex;
uniform float2 _Scale;
uniform float2 _Offset;
uniform half _LightMul;
uniform half _LightSourcesMul;
uniform half _AdditiveLightPow;
uniform half _AdditiveLightAdd;
uniform float2 _ExtendedToSmallTextureScale;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoordGame = v.texcoord;
o.texcoordLight = (o.texcoordGame - 0.5)*_Scale + 0.5 + _Offset;
o.texcoordAmbient = (o.texcoordLight - 0.5)*_ExtendedToSmallTextureScale + 0.5;
#if UNITY_UV_STARTS_AT_TOP
if (_GameTex_TexelSize.y < 0)
o.texcoordGame = half2(o.texcoordGame.x, 1 - o.texcoordGame.y);
#endif
return o;
}
half4 frag (v2f i) : COLOR
{
half4 game = tex2D(_GameTex, i.texcoordGame);
half4 ambientLight = tex2D(_AmbientLightTex, i.texcoordAmbient);
half4 lightSources = tex2D(_LightSourcesTex, i.texcoordLight)*_LightSourcesMul;
half4 light = ambientLight + lightSources;
half3 bloom = (game.rgb + _AdditiveLightAdd)*pow(light.rgb, _AdditiveLightPow)*step(0.005, _AdditiveLightPow);
return half4(game.rgb*light.rgb*_LightMul + bloom, game.a);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: b3670fc9c29468e48a8d629a881af61c
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,91 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
That shader is used to merge light sources, abmient light and game textures into one.
*/
Shader "Light2D/Light Overlay Single Camera" {
Properties {
_GameTex ("Game", 2D) = "white" {}
_AmbientLightTex ("Ambient Light", 2D) = "black" {}
_LightSourcesTex ("Light Sources", 2D) = "black" {}
_LightSourcesMul ("Light Sources Multiplier", Float) = 1
_LightMul ("Resulting Light Multiplier", Float) = 2
_AdditiveLightPow ("Bloom Pow. Zero to turn off bloom.", Float) = 10
_AdditiveLightAdd ("Bloom Add", Float) = 0.2
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY HDR
#pragma multi_compile BLOOM_ON BLOOM_OFF
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoordGame : TEXCOORD0;
half2 texcoordLight : TEXCOORD1;
half2 texcoordAmbient : TEXCOORD2;
};
uniform sampler2D _MainTex;
uniform sampler2D _GameTex;
uniform half4 _GameTex_TexelSize;
uniform sampler2D _AmbientLightTex;
uniform sampler2D _LightSourcesTex;
uniform float2 _Scale;
uniform float2 _Offest;
uniform half _LightMul;
uniform half _LightSourcesMul;
uniform half _AdditiveLightPow;
uniform half _AdditiveLightAdd;
uniform float2 _ExtendedToSmallTextureScale;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoordGame = v.texcoord;
o.texcoordLight = (o.texcoordGame - 0.5)*_Scale + 0.5 + _Offest;
o.texcoordAmbient = (o.texcoordLight - 0.5)*_ExtendedToSmallTextureScale + 0.5;
#if UNITY_UV_STARTS_AT_TOP
if (_GameTex_TexelSize.y < 0)
o.texcoordGame = half2(o.texcoordGame.x, 1 - o.texcoordGame.y);
#endif
return o;
}
half4 frag (v2f i) : COLOR
{
half4 game = tex2D(_GameTex, i.texcoordGame);
half4 ambientLight = tex2D(_AmbientLightTex, i.texcoordAmbient);
half4 lightSources = tex2D(_LightSourcesTex, i.texcoordLight)*_LightSourcesMul;
half4 light = ambientLight + lightSources;
half3 bloom = (game.rgb + _AdditiveLightAdd)*pow(light.rgb, _AdditiveLightPow)*step(0.005, _AdditiveLightPow);
return half4(game.rgb*light.rgb*_LightMul + bloom, game.a);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 0de7e208d31fc1242ab0a3ba9893e630
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,80 @@
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
Used to create normal map buffer.
*/
Shader "Light2D/Internal/Normal Map Drawer" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_NormalTex ("Normalmap", 2D) = "bump" {}
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"LightObstacle"="True"
}
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
Lighting Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 tangent : TANGENT;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 mainTexcoord : TEXCOORD0;
half2 normalTexcoord : TEXCOORD1;
half3 utangent : TEXCOORD2;
half3 vtangent : TEXCOORD3;
};
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _NormalTex;
float4 _NormalTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.mainTexcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.normalTexcoord = TRANSFORM_TEX(v.texcoord, _NormalTex);
o.utangent = normalize(mul((float3x3)unity_ObjectToWorld, half3(v.tangent.x, v.tangent.y, 0)));
o.vtangent = normalize(mul((float3x3)unity_ObjectToWorld, half3(v.tangent.y, -v.tangent.x, 0)));
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.mainTexcoord);
fixed2 bumpMap = normalize(UnpackNormal(tex2D(_NormalTex, i.normalTexcoord)));
bumpMap = -bumpMap;
fixed2 bump = bumpMap.x*i.utangent + bumpMap.y*i.vtangent;
fixed2 bumpOut = bump*0.5 + 0.5;
return fixed4(bumpOut, 0, col.a);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 20b15f631ada6ca4a93a0d75761b6d12
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,72 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
Used to create normal map buffer.
*/
Shader "Light2D/Internal/Normal Mapped Light" {
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
Blend OneMinusDstColor One
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
//float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 normalTexcoord : TEXCOORD0;
half2 lightTexcoord : TEXCOORD1;
half3 lightPos : TEXCOORD2;
};
uniform sampler2D _MainTex;
uniform sampler2D _NormalsBuffer;
uniform half3 _LightPos;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.normalTexcoord = o.vertex*0.5 + 0.5;
o.lightTexcoord = o.vertex*0.5 + 0.5;
o.lightPos = mul(UNITY_MATRIX_VP, half4(_LightPos.xy, 0, 1));
o.lightPos.z = _LightPos.z;
o.lightPos.xy = o.lightPos.xy*0.5 + 0.5;
#if UNITY_UV_STARTS_AT_TOP
o.normalTexcoord.y = 1 - o.normalTexcoord.y;
o.lightTexcoord.y = 1 - o.lightTexcoord.y;
o.lightPos.y = 1 - o.lightPos.y;
#endif
return o;
}
half4 frag (v2f i) : COLOR
{
half4 light = tex2D(_MainTex, i.lightTexcoord);
half3 normal = normalize(tex2D(_NormalsBuffer, i.normalTexcoord)*2.0 - 1.0);
half3 revLightDir = normalize(i.lightPos - half3(i.lightTexcoord, 0));
half lightness = max(0, -dot(normal, revLightDir));
return half4(light.rgb*lightness, light.a);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 019b8b15916791041b5bc1574b16bc78
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,55 @@
/*
That shader is used after all light obstacles have been drawn to draw one pixel wide white corner over it.
*/
Shader "Light2D/Obstacle Texture Post Porcessor" {
SubShader {
Tags {"Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
Blend Off
ZTest Always
Cull Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
};
uniform sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = v.vertex;
o.color = v.color;
return o;
}
half4 frag (v2f i) : COLOR
{
clip(i.color.a - 0.01);
return i.color;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 132032be8004cd840adc401e99786b67
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,76 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
That shader is usually used to draw light obstacles.
Have main texture, additive color and multiplicative color.
First color is multipicative. It's grabbed from vertex color.
Second color is additive (RGB) and partially multiplicative (A). It's encoded in TEXCOORD1.
*/
Shader "Light2D/Transparent Dual Color Normal Mapped" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_NormalTex ("Normalmap", 2D) = "bump" {}
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"LightObstacle"="True"
}
LOD 100
Cull Off
ZWrite Off
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 color : COLOR0;
float2 texcoord1 : TEXCOORD1;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float4 color0 : COLOR0;
float4 color1 : COLOR1;
};
sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord0;
o.color0 = v.color;
o.color1 = float4(EncodeFloatRGBA(v.texcoord1.x).xyz, EncodeFloatRGBA(v.texcoord1.y).x);
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col*i.color0 + fixed4(i.color1.rgb, i.color1.a*i.color1.a*col.a*10);
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: a4b0d33bda33cd144862711ad1341c78
ShaderImporter:
defaultTextures: []
userData:

View file

@ -0,0 +1,72 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
/*
That shader is usually used to draw light obstacles.
Have main texture and multiplicative color.
*/
Shader "Light2D/Transparent Normal Mapped" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_NormalTex ("Normalmap", 2D) = "bump" {}
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"LightObstacle"="True"
}
LOD 100
Cull Off
ZWrite Off
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col*i.color;
}
ENDCG
}
}
}

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 561c964cee632944a93426dee73fa4d3
ShaderImporter:
defaultTextures: []
userData: