Retro VFX! (also airboarder works now) (#780)

* Super Retro VFX!

* Updated Screen Jump default

* also airboarder works now

---------

Co-authored-by: minenice55 <star.elementa@gmail.com>
This commit is contained in:
wookywok
2024-03-11 16:21:51 -05:00
committed by GitHub
parent bc93a7ab94
commit 92962fef26
915 changed files with 32248 additions and 73 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 887c5516912c2ab4e9a07d1e1b882df6
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -0,0 +1,52 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: de49249ea2b608c4a9ff8163814b51dc
timeCreated: 1489753963
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 35930d267d988154797d2ab08a2704ad
timeCreated: 1489754075
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,43 @@
// ALso used for Direct3D 11 "feature level 9.x" target for Windows Store and Windows Phone
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 0
#define UNITY_GATHER_SUPPORTED 0
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) sampler2D textureName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) sampler3D textureName
#define TEXTURE2D(textureName) sampler2D textureName
#define SAMPLER2D(samplerName)
#define TEXTURE3D(textureName) sampler3D textureName
#define SAMPLER3D(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) sampler2D textureName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName
#define TEXTURE3D_ARGS(textureName, samplerName) sampler3D textureName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) tex2D(textureName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) tex2Dlod(textureName, float4(coord2, 0.0, lod))
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) tex3D(textureName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) tex2D(textureName, icoord2 / texelSize)
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) tex2Dlod(textureName, float4(icoord2 / texelSize, 0.0, lod))
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH
#define UNITY_FLATTEN
#define UNITY_UNROLL
#define UNITY_LOOP
#define UNITY_FASTOPT
#define CBUFFER_START(name)
#define CBUFFER_END
#define FXAA_HLSL_3 1
#define SMAA_HLSL_3 1

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 06a01d52ddef95344ac28b690f98ec2d
timeCreated: 1489754265
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED 0 // Currently broken on Metal for some reason (May 2017)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#define FXAA_HLSL_4 1 // See UNITY_GATHER_SUPPORTED
#define SMAA_HLSL_4 1

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d4eb15fffa74d644bb594060c705f777
timeCreated: 1489753963
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
// For now OpenGL is considered at GLES2 level
#define UNITY_UV_STARTS_AT_TOP 0
#define UNITY_REVERSED_Z 0
#define UNITY_GATHER_SUPPORTED 0
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) sampler2D textureName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) sampler3D textureName
#define TEXTURE2D(textureName) sampler2D textureName
#define SAMPLER2D(samplerName)
#define TEXTURE3D(textureName) sampler3D textureName
#define SAMPLER3D(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) sampler2D textureName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName
#define TEXTURE3D_ARGS(textureName, samplerName) sampler3D textureName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) tex2D(textureName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) tex2Dlod(textureName, float4(coord2, 0.0, lod))
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) tex3D(textureName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) tex2D(textureName, icoord2 / texelSize)
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) tex2Dlod(textureName, float4(icoord2 / texelSize, 0.0, lod))
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#if SHADER_API_GLES
# define UNITY_BRANCH
# define UNITY_FLATTEN
# define UNITY_UNROLL
# define UNITY_LOOP
# define UNITY_FASTOPT
#else
# define UNITY_BRANCH [branch]
# define UNITY_FLATTEN [flatten]
# define UNITY_UNROLL [unroll]
# define UNITY_LOOP [loop]
# define UNITY_FASTOPT [fastopt]
#endif
#define CBUFFER_START(name)
#define CBUFFER_END
#define FXAA_HLSL_3 1
#define SMAA_HLSL_3 1
// pragma exclude_renderers is only supported since Unity 2018.1 for compute shaders
#if UNITY_VERSION < 201810 && !defined(SHADER_API_GLCORE)
# define DISABLE_COMPUTE_SHADERS 1
# define TRIVIAL_COMPUTE_KERNEL(name) [numthreads(1, 1, 1)] void name() {}
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 252ce283bdab48948b80f71920a4c7c8
timeCreated: 1489754265
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 0
#define UNITY_GATHER_SUPPORTED 0
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 0
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) sampler2D textureName
#define TEXTURE2D(textureName) sampler2D textureName
#define SAMPLER2D(samplerName)
#define TEXTURE2D_ARGS(textureName, samplerName) sampler2D textureName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) tex2D(textureName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) tex2Dlod(textureName, float4(coord2, 0.0, lod))
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) tex2D(textureName, icoord2 / texelSize)
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) tex2Dlod(textureName, float4(icoord2 / texelSize, 0.0, lod))
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) tex2D<float>(textureName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) tex2Dlod<float>(textureName, float4(coord2, 0.0, lod)).r
// 3D textures are not supported on Vita, use 2D to avoid compile errors.
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) sampler2D textureName
#define TEXTURE3D(textureName) sampler2D textureName
#define SAMPLER3D(samplerName)
#define TEXTURE3D_ARGS(textureName, samplerName) sampler2D textureName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) tex2D(textureName, coord3)
#define UNITY_BRANCH
#define UNITY_FLATTEN
#define UNITY_UNROLL
#define UNITY_LOOP
#define UNITY_FASTOPT
#define CBUFFER_START(name)
#define CBUFFER_END
#define FXAA_HLSL_3 1
#define SMAA_HLSL_3 1
// pragma exclude_renderers is only supported since Unity 2018.1 for compute shaders
#if UNITY_VERSION < 201810 && !defined(SHADER_API_GLCORE)
# define DISABLE_COMPUTE_SHADERS 1
# define TRIVIAL_COMPUTE_KERNEL(name) [numthreads(1, 1, 1)] void name() {}
#endif

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b9ab41f4ad3d23642ad3d2ed0fdb18d6
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,55 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define INTRINSIC_MINMAX3
#define Min3 min3
#define Max3 max3
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) ConstantBuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e851c3938cacdaa45b025b90da1731b2
timeCreated: 1489753963
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6f67be869064ea34298bc051ba9f3589
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e68962a8c3be55d489e1b3a614bfc152
timeCreated: 1489754021
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_GATHER_SUPPORTED (SHADER_TARGET >= 50)
#define UNITY_CAN_READ_POSITION_IN_FRAGMENT_PROGRAM 1
#define TEXTURE2D_SAMPLER2D(textureName, samplerName) Texture2D textureName; SamplerState samplerName
#define TEXTURE3D_SAMPLER3D(textureName, samplerName) Texture3D textureName; SamplerState samplerName
#define TEXTURE2D(textureName) Texture2D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define LOAD_TEXTURE2D(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, texelSize, icoord2) textureName.Load(int3(icoord2, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
#define UNITY_BRANCH [branch]
#define UNITY_FLATTEN [flatten]
#define UNITY_UNROLL [unroll]
#define UNITY_LOOP [loop]
#define UNITY_FASTOPT [fastopt]
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
#if UNITY_GATHER_SUPPORTED
#define FXAA_HLSL_5 1
#define SMAA_HLSL_4_1 1
#else
#define FXAA_HLSL_4 1
#define SMAA_HLSL_4 1
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a71cfe7924c81774b8b60914e582f72b
timeCreated: 1489754021
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@

float3 BlendAdditive(float3 a, float3 b)
{
return a + b;
}
float3 BlendExclusion(float3 a, float3 b)
{
return a + b - 2.0 * a * b;
}
float3 BlendLighten(float3 a, float3 b)
{
return max(a, b);
}
//single channel overlay
float BlendOverlay(float a, float b)
{
return (b < 0.5) ? 2.0 * a * b : 1.0 - 2.0 * (1.0 - a) * (1.0 - b);
}
//RGB overlay
float3 BlendOverlay(float3 a, float3 b)
{
float3 color;
color.r = BlendOverlay(a.r, b.r);
color.g = BlendOverlay(a.g, b.g);
color.b = BlendOverlay(a.b, b.b);
return color;
}
float3 BlendScreen(float3 a, float3 b)
{
return a + b - a * b;
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cb852e8e66981284395c564808e301f5
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,650 @@
#ifndef UNITY_POSTFX_COLOR
#define UNITY_POSTFX_COLOR
#include "StdLib.hlsl"
#include "ACES.hlsl"
#define LUT_SPACE_ENCODE(x) LinearToLogC(x)
#define LUT_SPACE_DECODE(x) LogCToLinear(x)
#ifndef USE_PRECISE_LOGC
// Set to 1 to use more precise but more expensive log/linear conversions. I haven't found a proper
// use case for the high precision version yet so I'm leaving this to 0.
#define USE_PRECISE_LOGC 0
#endif
#ifndef TONEMAPPING_USE_FULL_ACES
// Set to 1 to use the full reference ACES tonemapper. This should only be used for research
// purposes as it's quite heavy and generally overkill.
#define TONEMAPPING_USE_FULL_ACES 0
#endif
#ifndef DEFAULT_MAX_PQ
// PQ ST.2048 max value
// 1.0 = 100nits, 100.0 = 10knits
#define DEFAULT_MAX_PQ 100.0
#endif
#ifndef USE_VERY_FAST_SRGB
#if defined(SHADER_API_MOBILE)
#define USE_VERY_FAST_SRGB 1
#else
#define USE_VERY_FAST_SRGB 0
#endif
#endif
#ifndef USE_FAST_SRGB
#if defined(SHADER_API_CONSOLE)
#define USE_FAST_SRGB 1
#else
#define USE_FAST_SRGB 0
#endif
#endif
//
// Alexa LogC converters (El 1000)
// See http://www.vocas.nl/webfm_send/964
// Max range is ~58.85666
//
struct ParamsLogC
{
float cut;
float a, b, c, d, e, f;
};
static const ParamsLogC LogC =
{
0.011361, // cut
5.555556, // a
0.047996, // b
0.244161, // c
0.386036, // d
5.301883, // e
0.092819 // f
};
float LinearToLogC_Precise(half x)
{
float o;
if (x > LogC.cut)
o = LogC.c * log10(LogC.a * x + LogC.b) + LogC.d;
else
o = LogC.e * x + LogC.f;
return o;
}
float3 LinearToLogC(float3 x)
{
#if USE_PRECISE_LOGC
return float3(
LinearToLogC_Precise(x.x),
LinearToLogC_Precise(x.y),
LinearToLogC_Precise(x.z)
);
#else
return LogC.c * log10(LogC.a * x + LogC.b) + LogC.d;
#endif
}
float LogCToLinear_Precise(float x)
{
float o;
if (x > LogC.e * LogC.cut + LogC.f)
o = (pow(10.0, (x - LogC.d) / LogC.c) - LogC.b) / LogC.a;
else
o = (x - LogC.f) / LogC.e;
return o;
}
float3 LogCToLinear(float3 x)
{
#if USE_PRECISE_LOGC
return float3(
LogCToLinear_Precise(x.x),
LogCToLinear_Precise(x.y),
LogCToLinear_Precise(x.z)
);
#else
return (pow(10.0, (x - LogC.d) / LogC.c) - LogC.b) / LogC.a;
#endif
}
//
// SMPTE ST.2084 (PQ) transfer functions
// Used for HDR Lut storage, max range depends on the maxPQValue parameter
//
struct ParamsPQ
{
float N, M;
float C1, C2, C3;
};
static const ParamsPQ PQ =
{
2610.0 / 4096.0 / 4.0, // N
2523.0 / 4096.0 * 128.0, // M
3424.0 / 4096.0, // C1
2413.0 / 4096.0 * 32.0, // C2
2392.0 / 4096.0 * 32.0, // C3
};
float3 LinearToPQ(float3 x, float maxPQValue)
{
x = PositivePow(x / maxPQValue, PQ.N);
float3 nd = (PQ.C1 + PQ.C2 * x) / (1.0 + PQ.C3 * x);
return PositivePow(nd, PQ.M);
}
float3 LinearToPQ(float3 x)
{
return LinearToPQ(x, DEFAULT_MAX_PQ);
}
float3 PQToLinear(float3 x, float maxPQValue)
{
x = PositivePow(x, rcp(PQ.M));
float3 nd = max(x - PQ.C1, 0.0) / (PQ.C2 - (PQ.C3 * x));
return PositivePow(nd, rcp(PQ.N)) * maxPQValue;
}
float3 PQToLinear(float3 x)
{
return PQToLinear(x, DEFAULT_MAX_PQ);
}
//
// sRGB transfer functions
// Fast path ref: http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1
//
half SRGBToLinear(half c)
{
#if USE_VERY_FAST_SRGB
return c * c;
#elif USE_FAST_SRGB
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
#else
half linearRGBLo = c / 12.92;
half linearRGBHi = PositivePow((c + 0.055) / 1.055, 2.4);
half linearRGB = (c <= 0.04045) ? linearRGBLo : linearRGBHi;
return linearRGB;
#endif
}
half3 SRGBToLinear(half3 c)
{
#if USE_VERY_FAST_SRGB
return c * c;
#elif USE_FAST_SRGB
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
#else
half3 linearRGBLo = c / 12.92;
half3 linearRGBHi = PositivePow((c + 0.055) / 1.055, half3(2.4, 2.4, 2.4));
half3 linearRGB = (c <= 0.04045) ? linearRGBLo : linearRGBHi;
return linearRGB;
#endif
}
half4 SRGBToLinear(half4 c)
{
return half4(SRGBToLinear(c.rgb), c.a);
}
half LinearToSRGB(half c)
{
#if USE_VERY_FAST_SRGB
return sqrt(c);
#elif USE_FAST_SRGB
return max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);
#else
half sRGBLo = c * 12.92;
half sRGBHi = (PositivePow(c, 1.0 / 2.4) * 1.055) - 0.055;
half sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi;
return sRGB;
#endif
}
half3 LinearToSRGB(half3 c)
{
#if USE_VERY_FAST_SRGB
return sqrt(c);
#elif USE_FAST_SRGB
return max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);
#else
half3 sRGBLo = c * 12.92;
half3 sRGBHi = (PositivePow(c, half3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4)) * 1.055) - 0.055;
half3 sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi;
return sRGB;
#endif
}
half4 LinearToSRGB(half4 c)
{
return half4(LinearToSRGB(c.rgb), c.a);
}
//
// Convert rgb to luminance with rgb in linear space with sRGB primaries and D65 white point
//
half Luminance(half3 linearRgb)
{
return dot(linearRgb, float3(0.2126729, 0.7151522, 0.0721750));
}
half Luminance(half4 linearRgba)
{
return Luminance(linearRgba.rgb);
}
//
// Quadratic color thresholding
// curve = (threshold - knee, knee * 2, 0.25 / knee)
//
half4 QuadraticThreshold(half4 color, half threshold, half3 curve)
{
// Pixel brightness
half br = Max3(color.r, color.g, color.b);
// Under-threshold part: quadratic curve
half rq = clamp(br - curve.x, 0.0, curve.y);
rq = curve.z * rq * rq;
// Combine and apply the brightness response curve.
color *= max(rq, br - threshold) / max(br, EPSILON);
return color;
}
//
// Fast reversible tonemapper
// http://gpuopen.com/optimized-reversible-tonemapper-for-resolve/
//
float3 FastTonemap(float3 c)
{
return c * rcp(Max3(c.r, c.g, c.b) + 1.0);
}
float4 FastTonemap(float4 c)
{
return float4(FastTonemap(c.rgb), c.a);
}
float3 FastTonemap(float3 c, float w)
{
return c * (w * rcp(Max3(c.r, c.g, c.b) + 1.0));
}
float4 FastTonemap(float4 c, float w)
{
return float4(FastTonemap(c.rgb, w), c.a);
}
float3 FastTonemapInvert(float3 c)
{
return c * rcp(1.0 - Max3(c.r, c.g, c.b));
}
float4 FastTonemapInvert(float4 c)
{
return float4(FastTonemapInvert(c.rgb), c.a);
}
//
// Neutral tonemapping (Hable/Hejl/Frostbite)
// Input is linear RGB
//
float3 NeutralCurve(float3 x, float a, float b, float c, float d, float e, float f)
{
return ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f;
}
float3 NeutralTonemap(float3 x)
{
// Tonemap
float a = 0.2;
float b = 0.29;
float c = 0.24;
float d = 0.272;
float e = 0.02;
float f = 0.3;
float whiteLevel = 5.3;
float whiteClip = 1.0;
float3 whiteScale = (1.0).xxx / NeutralCurve(whiteLevel, a, b, c, d, e, f);
x = NeutralCurve(x * whiteScale, a, b, c, d, e, f);
x *= whiteScale;
// Post-curve white point adjustment
x /= whiteClip.xxx;
return x;
}
//
// Raw, unoptimized version of John Hable's artist-friendly tone curve
// Input is linear RGB
//
float EvalCustomSegment(float x, float4 segmentA, float2 segmentB)
{
const float kOffsetX = segmentA.x;
const float kOffsetY = segmentA.y;
const float kScaleX = segmentA.z;
const float kScaleY = segmentA.w;
const float kLnA = segmentB.x;
const float kB = segmentB.y;
float x0 = (x - kOffsetX) * kScaleX;
float y0 = (x0 > 0.0) ? exp(kLnA + kB * log(x0)) : 0.0;
return y0 * kScaleY + kOffsetY;
}
float EvalCustomCurve(float x, float3 curve, float4 toeSegmentA, float2 toeSegmentB, float4 midSegmentA, float2 midSegmentB, float4 shoSegmentA, float2 shoSegmentB)
{
float4 segmentA;
float2 segmentB;
if (x < curve.y)
{
segmentA = toeSegmentA;
segmentB = toeSegmentB;
}
else if (x < curve.z)
{
segmentA = midSegmentA;
segmentB = midSegmentB;
}
else
{
segmentA = shoSegmentA;
segmentB = shoSegmentB;
}
return EvalCustomSegment(x, segmentA, segmentB);
}
// curve: x: inverseWhitePoint, y: x0, z: x1
float3 CustomTonemap(float3 x, float3 curve, float4 toeSegmentA, float2 toeSegmentB, float4 midSegmentA, float2 midSegmentB, float4 shoSegmentA, float2 shoSegmentB)
{
float3 normX = x * curve.x;
float3 ret;
ret.x = EvalCustomCurve(normX.x, curve, toeSegmentA, toeSegmentB, midSegmentA, midSegmentB, shoSegmentA, shoSegmentB);
ret.y = EvalCustomCurve(normX.y, curve, toeSegmentA, toeSegmentB, midSegmentA, midSegmentB, shoSegmentA, shoSegmentB);
ret.z = EvalCustomCurve(normX.z, curve, toeSegmentA, toeSegmentB, midSegmentA, midSegmentB, shoSegmentA, shoSegmentB);
return ret;
}
//
// Filmic tonemapping (ACES fitting, unless TONEMAPPING_USE_FULL_ACES is set to 1)
// Input is ACES2065-1 (AP0 w/ linear encoding)
//
float3 AcesTonemap(float3 aces)
{
#if TONEMAPPING_USE_FULL_ACES
float3 oces = RRT(aces);
float3 odt = ODT_RGBmonitor_100nits_dim(oces);
return odt;
#else
// --- Glow module --- //
float saturation = rgb_2_saturation(aces);
float ycIn = rgb_2_yc(aces);
float s = sigmoid_shaper((saturation - 0.4) / 0.2);
float addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);
aces *= addedGlow;
// --- Red modifier --- //
float hue = rgb_2_hue(aces);
float centeredHue = center_hue(hue, RRT_RED_HUE);
float hueWeight;
{
//hueWeight = cubic_basis_shaper(centeredHue, RRT_RED_WIDTH);
hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));
hueWeight *= hueWeight;
}
aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);
// --- ACES to RGB rendering space --- //
float3 acescg = max(0.0, ACES_to_ACEScg(aces));
// --- Global desaturation --- //
//acescg = mul(RRT_SAT_MAT, acescg);
acescg = lerp(dot(acescg, AP1_RGB2Y).xxx, acescg, RRT_SAT_FACTOR.xxx);
// Luminance fitting of *RRT.a1.0.3 + ODT.Academy.RGBmonitor_100nits_dim.a1.0.3*.
// https://github.com/colour-science/colour-unity/blob/master/Assets/Colour/Notebooks/CIECAM02_Unity.ipynb
// RMSE: 0.0012846272106
const float a = 278.5085;
const float b = 10.7772;
const float c = 293.6045;
const float d = 88.7122;
const float e = 80.6889;
float3 x = acescg;
float3 rgbPost = (x * (a * x + b)) / (x * (c * x + d) + e);
// Scale luminance to linear code value
// float3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
// Apply gamma adjustment to compensate for dim surround
float3 linearCV = darkSurround_to_dimSurround(rgbPost);
// Apply desaturation to compensate for luminance difference
//linearCV = mul(ODT_SAT_MAT, color);
linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
// Convert to display primary encoding
// Rendering space RGB to XYZ
float3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
// Apply CAT from ACES white point to assumed observer adapted white point
XYZ = mul(D60_2_D65_CAT, XYZ);
// CIE XYZ to display primaries
linearCV = mul(XYZ_2_REC709_MAT, XYZ);
return linearCV;
#endif
}
//
// 3D LUT grading
// scaleOffset = (1 / lut_size, lut_size - 1)
//
half3 ApplyLut3D(TEXTURE3D_ARGS(tex, samplerTex), float3 uvw, float2 scaleOffset)
{
uvw.xyz = uvw.xyz * scaleOffset.yyy * scaleOffset.xxx + scaleOffset.xxx * 0.5;
return SAMPLE_TEXTURE3D(tex, samplerTex, uvw).rgb;
}
//
// 2D LUT grading
// scaleOffset = (1 / lut_width, 1 / lut_height, lut_height - 1)
//
half3 ApplyLut2D(TEXTURE2D_ARGS(tex, samplerTex), float3 uvw, float3 scaleOffset)
{
// Strip format where `height = sqrt(width)`
uvw.z *= scaleOffset.z;
float shift = floor(uvw.z);
uvw.xy = uvw.xy * scaleOffset.z * scaleOffset.xy + scaleOffset.xy * 0.5;
uvw.x += shift * scaleOffset.y;
uvw.xyz = lerp(
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy).rgb,
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy + float2(scaleOffset.y, 0.0)).rgb,
uvw.z - shift
);
return uvw;
}
//
// Returns the default value for a given position on a 2D strip-format color lookup table
// params = (lut_height, 0.5 / lut_width, 0.5 / lut_height, lut_height / lut_height - 1)
//
float3 GetLutStripValue(float2 uv, float4 params)
{
uv -= params.yz;
float3 color;
color.r = frac(uv.x * params.x);
color.b = uv.x - color.r / params.x;
color.g = uv.y;
return color * params.w;
}
//
// White balance
// Recommended workspace: ACEScg (linear)
//
static const float3x3 LIN_2_LMS_MAT = {
3.90405e-1, 5.49941e-1, 8.92632e-3,
7.08416e-2, 9.63172e-1, 1.35775e-3,
2.31082e-2, 1.28021e-1, 9.36245e-1
};
static const float3x3 LMS_2_LIN_MAT = {
2.85847e+0, -1.62879e+0, -2.48910e-2,
-2.10182e-1, 1.15820e+0, 3.24281e-4,
-4.18120e-2, -1.18169e-1, 1.06867e+0
};
float3 WhiteBalance(float3 c, float3 balance)
{
float3 lms = mul(LIN_2_LMS_MAT, c);
lms *= balance;
return mul(LMS_2_LIN_MAT, lms);
}
//
// RGB / Full-range YCbCr conversions (ITU-R BT.601)
//
float3 RgbToYCbCr(float3 c)
{
float Y = 0.299 * c.r + 0.587 * c.g + 0.114 * c.b;
float Cb = -0.169 * c.r - 0.331 * c.g + 0.500 * c.b;
float Cr = 0.500 * c.r - 0.419 * c.g - 0.081 * c.b;
return float3(Y, Cb, Cr);
}
float3 YCbCrToRgb(float3 c)
{
float R = c.x + 0.000 * c.y + 1.403 * c.z;
float G = c.x - 0.344 * c.y - 0.714 * c.z;
float B = c.x - 1.773 * c.y + 0.000 * c.z;
return float3(R, G, B);
}
//
// Hue, Saturation, Value
// Ranges:
// Hue [0.0, 1.0]
// Sat [0.0, 1.0]
// Lum [0.0, HALF_MAX]
//
float3 RgbToHsv(float3 c)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = EPSILON;
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
float3 HsvToRgb(float3 c)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
float RotateHue(float value, float low, float hi)
{
return (value < low)
? value + hi
: (value > hi)
? value - hi
: value;
}
//
// RGB Saturation (closer to a vibrance effect than actual saturation)
// Recommended workspace: ACEScg (linear)
// Optimal range: [0.0, 2.0]
//
float3 Saturation(float3 c, float sat)
{
float luma = Luminance(c);
return luma.xxx + sat.xxx * (c - luma.xxx);
}
//
// Contrast (reacts better when applied in log)
// Optimal range: [0.0, 2.0]
//
float3 Contrast(float3 c, float midpoint, float contrast)
{
return (c - midpoint) * contrast + midpoint;
}
//
// Lift, Gamma (pre-inverted), Gain tuned for HDR use - best used with the ACES tonemapper as
// negative values will creep in the result
// Expected workspace: ACEScg (linear)
//
float3 LiftGammaGainHDR(float3 c, float3 lift, float3 invgamma, float3 gain)
{
c = c * gain + lift;
// ACEScg will output negative values, as clamping to 0 will lose precious information we'll
// mirror the gamma function instead
return FastSign(c) * pow(abs(c), invgamma);
}
//
// Lift, Gamma (pre-inverted), Gain tuned for LDR use
// Input is linear RGB
//
float3 LiftGammaGainLDR(float3 c, float3 lift, float3 invgamma, float3 gain)
{
c = saturate(PositivePow(saturate(c), invgamma));
return gain * c + lift * (1.0 - c);
}
//
// Remaps Y/R/G/B values
// curveTex has to be 128 pixels wide
//
float3 YrgbCurve(float3 c, TEXTURE2D_ARGS(curveTex, sampler_curveTex))
{
const float kHalfPixel = (1.0 / 128.0) / 2.0;
// Y (master)
c += kHalfPixel.xxx;
float mr = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.r, 0.75)).a;
float mg = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.g, 0.75)).a;
float mb = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.b, 0.75)).a;
c = saturate(float3(mr, mg, mb));
// RGB
c += kHalfPixel.xxx;
float r = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.r, 0.75)).r;
float g = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.g, 0.75)).g;
float b = SAMPLE_TEXTURE2D(curveTex, sampler_curveTex, float2(c.b, 0.75)).b;
return saturate(float3(r, g, b));
}
//
// Channel mixing (same as Photoshop's and DaVinci's Resolve)
// Recommended workspace: ACEScg (linear)
// Input mixers should be in range [-2.0; 2.0]
//
float3 ChannelMixer(float3 c, float3 red, float3 green, float3 blue)
{
return float3(
dot(c, red),
dot(c, green),
dot(c, blue)
);
}
#endif // UNITY_POSTFX_COLOR

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c538cea31550b1f4f8300803095caa5b
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -0,0 +1,118 @@
Shader "Hidden/PostProcessing/Editor/ColorWheel"
{
CGINCLUDE
#include "UnityCG.cginc"
#define PI 3.14159265359
#define PI2 6.28318530718
float _Offset;
float _DisabledState;
float2 _Resolution; // x: size, y: size / 2
float3 HsvToRgb(float3 c)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
float4 CreateWheel(v2f_img i, float crossColor, float offsetColor)
{
const float kHueOuterRadius = 0.45;
const float kHueInnerRadius = 0.28;////adjust to 0.28
const float kLumOuterRadius = 0.495;
const float kLumInnerRadius = 0.48;
float4 color = (0.0).xxxx;
float2 uvc = i.uv - (0.5).xx;
float dist = sqrt(dot(uvc, uvc));
float delta = fwidth(dist);
float angle = atan2(uvc.x, uvc.y);
// Cross
{
float radius = (0.5 - kHueInnerRadius) * _Resolution.x + 1.0;
float2 pixel = (_Resolution.xx - 1.0) * i.uv + 1.0;
float vline = step(floor(fmod(pixel.x, _Resolution.y)), 0.0);
vline *= step(radius, pixel.y) * step(pixel.y, _Resolution.x - radius);
float hline = step(floor(fmod(pixel.y, _Resolution.y)), 0.0);
hline *= step(radius, pixel.x) * step(pixel.x, _Resolution.x - radius);
color += hline.xxxx * (1.0).xxxx;
color += vline.xxxx * (1.0).xxxx;
color = saturate(color);
color *= half4((crossColor).xxx, 0.05);
}
// Hue
{
float alphaOut = smoothstep(kHueOuterRadius - delta, kHueOuterRadius + delta, dist);
float alphaIn = smoothstep(kHueInnerRadius - delta, kHueInnerRadius + delta, dist);
float hue = angle;
hue = 1.0 - ((hue > 0.0) ? hue : PI2 + hue) / PI2;
float4 c = float4(HsvToRgb(float3(hue, 1.0, 1.0)), 1.0);
color += lerp((0.0).xxxx, c, alphaIn - alphaOut);
}
// Offset
{
float alphaOut = smoothstep(kLumOuterRadius - delta, kLumOuterRadius + delta, dist);
float alphaIn = smoothstep(kLumInnerRadius - delta, kLumInnerRadius + delta / 2, dist);
float4 c = float4((offsetColor).xxx, 1.0);
float a = PI * _Offset;
if (_Offset >= 0 && angle < a && angle > 0.0)
c = float4((1.0).xxx, 0.5);
else if (angle > a && angle < 0.0)
c = float4((1.0).xxx, 0.5);
color += lerp((0.0).xxxx, c, alphaIn - alphaOut);
}
return color * _DisabledState;
}
float4 FragTrackballDark(v2f_img i) : SV_Target
{
return CreateWheel(i, 1.0, 0.15);
}
float4 FragTrackballLight(v2f_img i) : SV_Target
{
return CreateWheel(i, 0.0, 0.3);
}
ENDCG
SubShader
{
Cull Off ZWrite Off ZTest Always
// (0) Dark skin
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment FragTrackballDark
ENDCG
}
// (1) Light skin
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment FragTrackballLight
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 275649fd4f3bf9e449217f111493d01d
timeCreated: 1493903699
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,5 @@
Post-processing copyright ?2017 Unity Technologies ApS
Licensed under the Unity Companion License for Unity-dependent projects--see Unity Companion License.
Unless expressly provided otherwise, the Software under this license is made available strictly on an <20>AS IS?BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4a573eb73ecca5a47a5920beb8234377
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,91 @@
#ifndef UNITY_POSTFX_SAMPLING
#define UNITY_POSTFX_SAMPLING
#include "StdLib.hlsl"
// Better, temporally stable box filtering
// [Jimenez14] http://goo.gl/eomGso
// . . . . . . .
// . A . B . C .
// . . D . E . .
// . F . G . H .
// . . I . J . .
// . K . L . M .
// . . . . . . .
half4 DownsampleBox13Tap(TEXTURE2D_ARGS(tex, samplerTex), float2 uv, float2 texelSize)
{
half4 A = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2(-1.0, -1.0)));
half4 B = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 0.0, -1.0)));
half4 C = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 1.0, -1.0)));
half4 D = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2(-0.5, -0.5)));
half4 E = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 0.5, -0.5)));
half4 F = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2(-1.0, 0.0)));
half4 G = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv ));
half4 H = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 1.0, 0.0)));
half4 I = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2(-0.5, 0.5)));
half4 J = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 0.5, 0.5)));
half4 K = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2(-1.0, 1.0)));
half4 L = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 0.0, 1.0)));
half4 M = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + texelSize * float2( 1.0, 1.0)));
half2 div = (1.0 / 4.0) * half2(0.5, 0.125);
half4 o = (D + E + I + J) * div.x;
o += (A + B + G + F) * div.y;
o += (B + C + H + G) * div.y;
o += (F + G + L + K) * div.y;
o += (G + H + M + L) * div.y;
return o;
}
// Standard box filtering
half4 DownsampleBox4Tap(TEXTURE2D_ARGS(tex, samplerTex), float2 uv, float2 texelSize)
{
float4 d = texelSize.xyxy * float4(-1.0, -1.0, 1.0, 1.0);
half4 s;
s = (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xy)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zy)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xw)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zw)));
return s * (1.0 / 4.0);
}
// 9-tap bilinear upsampler (tent filter)
half4 UpsampleTent(TEXTURE2D_ARGS(tex, samplerTex), float2 uv, float2 texelSize, float4 sampleScale)
{
float4 d = texelSize.xyxy * float4(1.0, 1.0, -1.0, 0.0) * sampleScale;
half4 s;
s = SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv - d.xy));
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv - d.wy)) * 2.0;
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv - d.zy));
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zw)) * 2.0;
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv )) * 4.0;
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xw)) * 2.0;
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zy));
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.wy)) * 2.0;
s += SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xy));
return s * (1.0 / 16.0);
}
// Standard box filtering
half4 UpsampleBox(TEXTURE2D_ARGS(tex, samplerTex), float2 uv, float2 texelSize, float4 sampleScale)
{
float4 d = texelSize.xyxy * float4(-1.0, -1.0, 1.0, 1.0) * (sampleScale * 0.5);
half4 s;
s = (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xy)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zy)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.xw)));
s += (SAMPLE_TEXTURE2D(tex, samplerTex, UnityStereoTransformScreenSpaceTex(uv + d.zw)));
return s * (1.0 / 4.0);
}
#endif // UNITY_POSTFX_SAMPLING

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e9e2fed3630276b438e33b9ca848266e
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,322 @@
// Because this framework is supposed to work with the legacy render pipelines AND scriptable render
// pipelines we can't use Unity's shader libraries (some scriptable pipelines come with their own
// shader lib). So here goes a minimal shader lib only used for post-processing to ensure good
// compatibility with all pipelines.
#ifndef UNITY_POSTFX_STDLIB
#define UNITY_POSTFX_STDLIB
// -----------------------------------------------------------------------------
// API macros
#if defined(SHADER_API_PSSL)
#include "API/PSSL.hlsl"
#elif defined(SHADER_API_XBOXONE)
#include "API/XboxOne.hlsl"
#elif defined(SHADER_API_D3D11)
#include "API/D3D11.hlsl"
#elif defined(SHADER_API_D3D12)
#include "API/D3D12.hlsl"
#elif defined(SHADER_API_D3D9) || defined(SHADER_API_D3D11_9X)
#include "API/D3D9.hlsl"
#elif defined(SHADER_API_VULKAN)
#include "API/Vulkan.hlsl"
#elif defined(SHADER_API_SWITCH)
#include "API/Switch.hlsl"
#elif defined(SHADER_API_METAL)
#include "API/Metal.hlsl"
#elif defined(SHADER_API_PSP2)
#include "API/PSP2.hlsl"
#else
#include "API/OpenGL.hlsl"
#endif
#if defined(SHADER_API_PSSL) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_SWITCH) || defined(SHADER_API_PSP2)
#define SHADER_API_CONSOLE
#endif
// -----------------------------------------------------------------------------
// Constants
#define HALF_MAX 65504.0 // (2 - 2^-10) * 2^15
#define HALF_MAX_MINUS1 65472.0 // (2 - 2^-9) * 2^15
#define EPSILON 1.0e-4
#define PI 3.14159265359
#define TWO_PI 6.28318530718
#define FOUR_PI 12.56637061436
#define INV_PI 0.31830988618
#define INV_TWO_PI 0.15915494309
#define INV_FOUR_PI 0.07957747155
#define HALF_PI 1.57079632679
#define INV_HALF_PI 0.636619772367
#define FLT_EPSILON 1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0
#define FLT_MIN 1.175494351e-38 // Minimum representable positive floating-point number
#define FLT_MAX 3.402823466e+38 // Maximum representable floating-point number
// -----------------------------------------------------------------------------
// Compatibility functions
#if (SHADER_TARGET < 50 && !defined(SHADER_API_PSSL))
float rcp(float value)
{
return 1.0 / value;
}
#endif
#if defined(SHADER_API_GLES)
#define mad(a, b, c) (a * b + c)
#endif
#ifndef INTRINSIC_MINMAX3
float Min3(float a, float b, float c)
{
return min(min(a, b), c);
}
float2 Min3(float2 a, float2 b, float2 c)
{
return min(min(a, b), c);
}
float3 Min3(float3 a, float3 b, float3 c)
{
return min(min(a, b), c);
}
float4 Min3(float4 a, float4 b, float4 c)
{
return min(min(a, b), c);
}
float Max3(float a, float b, float c)
{
return max(max(a, b), c);
}
float2 Max3(float2 a, float2 b, float2 c)
{
return max(max(a, b), c);
}
float3 Max3(float3 a, float3 b, float3 c)
{
return max(max(a, b), c);
}
float4 Max3(float4 a, float4 b, float4 c)
{
return max(max(a, b), c);
}
#endif // INTRINSIC_MINMAX3
// https://twitter.com/SebAaltonen/status/878250919879639040
// madd_sat + madd
float FastSign(float x)
{
return saturate(x * FLT_MAX + 0.5) * 2.0 - 1.0;
}
float2 FastSign(float2 x)
{
return saturate(x * FLT_MAX + 0.5) * 2.0 - 1.0;
}
float3 FastSign(float3 x)
{
return saturate(x * FLT_MAX + 0.5) * 2.0 - 1.0;
}
float4 FastSign(float4 x)
{
return saturate(x * FLT_MAX + 0.5) * 2.0 - 1.0;
}
// Using pow often result to a warning like this
// "pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them"
// PositivePow remove this warning when you know the value is positive and avoid inf/NAN.
float PositivePow(float base, float power)
{
return pow(max(abs(base), float(FLT_EPSILON)), power);
}
float2 PositivePow(float2 base, float2 power)
{
return pow(max(abs(base), float2(FLT_EPSILON, FLT_EPSILON)), power);
}
float3 PositivePow(float3 base, float3 power)
{
return pow(max(abs(base), float3(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);
}
float4 PositivePow(float4 base, float4 power)
{
return pow(max(abs(base), float4(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);
}
// NaN checker
// /Gic isn't enabled on fxc so we can't rely on isnan() anymore
bool IsNan(float x)
{
// For some reason the following tests outputs "internal compiler error" randomly on desktop
// so we'll use a safer but slightly slower version instead :/
//return (x <= 0.0 || 0.0 <= x) ? false : true;
return (x < 0.0 || x > 0.0 || x == 0.0) ? false : true;
}
bool AnyIsNan(float2 x)
{
return IsNan(x.x) || IsNan(x.y);
}
bool AnyIsNan(float3 x)
{
return IsNan(x.x) || IsNan(x.y) || IsNan(x.z);
}
bool AnyIsNan(float4 x)
{
return IsNan(x.x) || IsNan(x.y) || IsNan(x.z) || IsNan(x.w);
}
// -----------------------------------------------------------------------------
// Std unity data
float4x4 unity_CameraProjection;
float4x4 unity_MatrixVP;
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToCamera;
float3 _WorldSpaceCameraPos;
float4 _ProjectionParams; // x: 1 (-1 flipped), y: near, z: far, w: 1/far
float4 unity_ColorSpaceLuminance;
float4 unity_DeltaTime; // x: dt, y: 1/dt, z: smoothDt, w: 1/smoothDt
float4 unity_OrthoParams; // x: width, y: height, z: unused, w: ortho ? 1 : 0
float4 _ZBufferParams; // x: 1-far/near, y: far/near, z: x/far, w: y/far
float4 _ScreenParams; // x: width, y: height, z: 1+1/width, w: 1+1/height
float4 _Time; // x: t/20, y: t, z: t*2, w: t*3
float4 _SinTime; // x: sin(t/20), y: sin(t), z: sin(t*2), w: sin(t*3)
float4 _CosTime; // x: cos(t/20), y: cos(t), z: cos(t*2), w: cos(t*3)
// -----------------------------------------------------------------------------
// Std functions
// Z buffer depth to linear 0-1 depth
// Handles orthographic projection correctly
float Linear01Depth(float z)
{
float isOrtho = unity_OrthoParams.w;
float isPers = 1.0 - unity_OrthoParams.w;
z *= _ZBufferParams.x;
return (1.0 - isOrtho * z) / (isPers * z + _ZBufferParams.y);
}
float LinearEyeDepth(float z)
{
return rcp(_ZBufferParams.z * z + _ZBufferParams.w);
}
// Clamp HDR value within a safe range
half3 SafeHDR(half3 c)
{
return min(c, HALF_MAX);
}
half4 SafeHDR(half4 c)
{
return min(c, HALF_MAX);
}
// Decode normals stored in _CameraDepthNormalsTexture
float3 DecodeViewNormalStereo(float4 enc4)
{
float kScale = 1.7777;
float3 nn = enc4.xyz * float3(2.0 * kScale, 2.0 * kScale, 0) + float3(-kScale, -kScale, 1);
float g = 2.0 / dot(nn.xyz, nn.xyz);
float3 n;
n.xy = g * nn.xy;
n.z = g - 1.0;
return n;
}
// Interleaved gradient function from Jimenez 2014
// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
float GradientNoise(float2 uv)
{
uv = floor(uv * _ScreenParams.xy);
float f = dot(float2(0.06711056, 0.00583715), uv);
return frac(52.9829189 * frac(f));
}
// Vertex manipulation
float2 TransformTriangleVertexToUV(float2 vertex)
{
float2 uv = (vertex + 1.0) * 0.5;
return uv;
}
#include "xRLib.hlsl"
// -----------------------------------------------------------------------------
// Default vertex shaders
struct AttributesDefault
{
float3 vertex : POSITION;
};
struct VaryingsDefault
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoordStereo : TEXCOORD1;
#if STEREO_INSTANCING_ENABLED
uint stereoTargetEyeIndex : SV_RenderTargetArrayIndex;
#endif
};
#if STEREO_INSTANCING_ENABLED
float _DepthSlice;
#endif
VaryingsDefault VertDefault(AttributesDefault v)
{
VaryingsDefault o;
o.vertex = float4(v.vertex.xy, 0.0, 1.0);
o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
#if UNITY_UV_STARTS_AT_TOP
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
#endif
o.texcoordStereo = TransformStereoScreenSpaceTex(o.texcoord, 1.0);
return o;
}
float4 _UVTransform; // xy: scale, wz: translate
#if STEREO_DOUBLEWIDE_TARGET
float4 _PosScaleOffset; // xy: scale, wz: offset
#endif
VaryingsDefault VertUVTransform(AttributesDefault v)
{
VaryingsDefault o;
#if STEREO_DOUBLEWIDE_TARGET
o.vertex = float4(v.vertex.xy * _PosScaleOffset.xy + _PosScaleOffset.zw, 0.0, 1.0);
#else
o.vertex = float4(v.vertex.xy, 0.0, 1.0);
#endif
o.texcoord = TransformTriangleVertexToUV(v.vertex.xy) * _UVTransform.xy + _UVTransform.zw;
o.texcoordStereo = TransformStereoScreenSpaceTex(o.texcoord, 1.0);
#if STEREO_INSTANCING_ENABLED
o.stereoTargetEyeIndex = (uint)_DepthSlice;
#endif
return o;
}
#define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
#endif // UNITY_POSTFX_STDLIB

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 86258f1ffe58a0846997120fd95f2c5a
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,971 @@
//----------------------------------------------------------------------------------------------------------
// X-PostProcessing Library
// https://github.com/QianMo/X-PostProcessing-Library
// Copyright (C) 2020 QianMo. All rights reserved.
// Licensed under the MIT License
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
// http://opensource.org/licenses/MIT
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
// XNoiseLibrary.hlsl
// A Collection of 2D/3D/4D Simplex Noise 、 2D/3D textureless classic Noise 、Re-oriented 4 / 8-Point BCC Noise
//
// Reference 1: Webgl Noise - https://github.com/ashima/webgl-noise
// Reference 2: KdotJPG New Simplex Style Gradient Noise - https://github.com/KdotJPG/New-Simplex-Style-Gradient-Noise
// Reference 3: Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader
// Reference 4: noiseSimplex.cginc - https://forum.unity.com/threads/2d-3d-4d-optimised-perlin-noise-cg-hlsl-library-cginc.218372/
// ----------------------------------------------------------------------------------------------------------
#ifndef X_NOISE_LIBRARY
#define X_NOISE_LIBRARY
//==================================================================================================================================
// 0. Comon
//==================================================================================================================================
// 1 / 289
#define NOISE_SIMPLEX_1_DIV_289 0.00346020761245674740484429065744f
float mod289(float x)
{
return x - floor(x * NOISE_SIMPLEX_1_DIV_289) * 289.0;
}
float2 mod289(float2 x)
{
return x - floor(x * NOISE_SIMPLEX_1_DIV_289) * 289.0;
}
float3 mod289(float3 x)
{
return x - floor(x * NOISE_SIMPLEX_1_DIV_289) * 289.0;
}
float4 mod289(float4 x)
{
return x - floor(x * NOISE_SIMPLEX_1_DIV_289) * 289.0;
}
float4 mod(float4 x, float4 y)
{
return x - y * floor(x / y);
}
float3 mod(float3 x, float3 y)
{
return x - y * floor(x / y);
}
// ( x*34.0 + 1.0 )*x =x*x*34.0 + x
float permute(float x)
{
return mod289(x * x * 34.0 + x);
}
float3 permute(float3 x)
{
return mod289(x * x * 34.0 + x);
}
float4 permute(float4 x)
{
return mod289(x * x * 34.0 + x);
}
float3 taylorInvSqrt(float3 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
float4 taylorInvSqrt(float4 r)
{
return 1.79284291400159 - r * 0.85373472095314;
}
float2 fade(float2 t)
{
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
}
float3 fade(float3 t)
{
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
}
//==================================================================================================================================
// 1. Simplex Noise
//==================================================================================================================================
//
// This shader is based on the webgl-noise GLSL shader. For further details
// of the original shader, please see the following description from the
// original source code.
//
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
//
// Usage:
// float ns = snoise(v);
// v is any of: float2, float3, float4
// Return type is float.
// To generate 2 or more components of noise(colorful noise),
// call these functions several times with different
// constant offsets for the arguments.
// E.g.:
// float3 colorNs = float3(
// snoise(v),
// snoise(v + 17.0),
// snoise(v - 43.0),
// );
//----------------------------------------------------[1.1] 2D Simplex Noise ----------------------------------------------------
float snoise(float2 v)
{
const float4 C = float4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
- 0.577350269189626, // -1.0 + 2.0 * C.x
0.024390243902439); // 1.0 / 41.0
// First corner
float2 i = floor(v + dot(v, C.yy));
float2 x0 = v - i + dot(i, C.xx);
// Other corners
float2 i1;
i1.x = step(x0.y, x0.x);
i1.y = 1.0 - i1.x;
// x1 = x0 - i1 + 1.0 * C.xx;
// x2 = x0 - 1.0 + 2.0 * C.xx;
float2 x1 = x0 + C.xx - i1;
float2 x2 = x0 + C.zz;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0))
+ i.x + float3(0.0, i1.x, 1.0));
float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0);
m = m * m;
m = m * m;
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
float3 x = 2.0 * frac(p * C.www) - 1.0;
float3 h = abs(x) - 0.5;
float3 ox = floor(x + 0.5);
float3 a0 = x - ox;
// Normalise gradients implicitly by scaling m
m *= taylorInvSqrt(a0 * a0 + h * h);
// Compute final noise value at P
float3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.y = a0.y * x1.x + h.y * x1.y;
g.z = a0.z * x2.x + h.z * x2.y;
return 130.0 * dot(m, g);
}
float3 snoise_grad(float2 v)
{
const float4 C = float4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
- 0.577350269189626, // -1.0 + 2.0 * C.x
0.024390243902439); // 1.0 / 41.0
// First corner
float2 i = floor(v + dot(v, C.yy));
float2 x0 = v - i + dot(i, C.xx);
// Other corners
float2 i1;
i1.x = step(x0.y, x0.x);
i1.y = 1.0 - i1.x;
// x1 = x0 - i1 + 1.0 * C.xx;
// x2 = x0 - 1.0 + 2.0 * C.xx;
float2 x1 = x0 + C.xx - i1;
float2 x2 = x0 + C.zz;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0))
+ i.x + float3(0.0, i1.x, 1.0));
float3 m = max(0.5 - float3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0);
float3 m2 = m * m;
float3 m3 = m2 * m;
float3 m4 = m2 * m2;
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
float3 x = 2.0 * frac(p * C.www) - 1.0;
float3 h = abs(x) - 0.5;
float3 ox = floor(x + 0.5);
float3 a0 = x - ox;
// Normalise gradients
float3 norm = taylorInvSqrt(a0 * a0 + h * h);
float2 g0 = float2(a0.x, h.x) * norm.x;
float2 g1 = float2(a0.y, h.y) * norm.y;
float2 g2 = float2(a0.z, h.z) * norm.z;
// Compute noise and gradient at P
float2 grad = -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 +
- 6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 +
- 6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2;
float3 px = float3(dot(x0, g0), dot(x1, g1), dot(x2, g2));
return 130.0 * float3(grad, dot(m4, px));
}
//---------------------------------------------------[1.2] 3D Simplex Noise ---------------------------------------------
float snoise(float3 v)
{
const float2 C = float2(1.0 / 6.0, 1.0 / 3.0);
// First corner
float3 i = floor(v + dot(v, C.yyy));
float3 x0 = v - i + dot(i, C.xxx);
// Other corners
float3 g = step(x0.yzx, x0.xyz);
float3 l = 1.0 - g;
float3 i1 = min(g.xyz, l.zxy);
float3 i2 = max(g.xyz, l.zxy);
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
float3 x1 = x0 - i1 + C.xxx;
float3 x2 = x0 - i2 + C.yyy;
float3 x3 = x0 - 0.5;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
float4 p = permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0))
+ i.y + float4(0.0, i1.y, i2.y, 1.0))
+ i.x + float4(0.0, i1.x, i2.x, 1.0));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7)
float4 x_ = floor(j / 7.0);
float4 y_ = floor(j - 7.0 * x_); // mod(j,N)
float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 h = 1.0 - abs(x) - abs(y);
float4 b0 = float4(x.xy, y.xy);
float4 b1 = float4(x.zw, y.zw);
//float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0;
//float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0;
float4 s0 = floor(b0) * 2.0 + 1.0;
float4 s1 = floor(b1) * 2.0 + 1.0;
float4 sh = -step(h, 0.0);
float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
float4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
float3 g0 = float3(a0.xy, h.x);
float3 g1 = float3(a0.zw, h.y);
float3 g2 = float3(a1.xy, h.z);
float3 g3 = float3(a1.zw, h.w);
// Normalise gradients
float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3)));
g0 *= norm.x;
g1 *= norm.y;
g2 *= norm.z;
g3 *= norm.w;
// Mix final noise value
float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);
m = m * m;
m = m * m;
float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3));
return 42.0 * dot(m, px);
}
float4 snoise_grad(float3 v)
{
const float2 C = float2(1.0 / 6.0, 1.0 / 3.0);
// First corner
float3 i = floor(v + dot(v, C.yyy));
float3 x0 = v - i + dot(i, C.xxx);
// Other corners
float3 g = step(x0.yzx, x0.xyz);
float3 l = 1.0 - g;
float3 i1 = min(g.xyz, l.zxy);
float3 i2 = max(g.xyz, l.zxy);
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
float3 x1 = x0 - i1 + C.xxx;
float3 x2 = x0 - i2 + C.yyy;
float3 x3 = x0 - 0.5;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
float4 p = permute(permute(permute(i.z + float4(0.0, i1.z, i2.z, 1.0))
+ i.y + float4(0.0, i1.y, i2.y, 1.0))
+ i.x + float4(0.0, i1.x, i2.x, 1.0));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float4 j = p - 49.0 * floor(p / 49.0); // mod(p,7*7)
float4 x_ = floor(j / 7.0);
float4 y_ = floor(j - 7.0 * x_); // mod(j,N)
float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 h = 1.0 - abs(x) - abs(y);
float4 b0 = float4(x.xy, y.xy);
float4 b1 = float4(x.zw, y.zw);
//float4 s0 = float4(lessThan(b0, 0.0)) * 2.0 - 1.0;
//float4 s1 = float4(lessThan(b1, 0.0)) * 2.0 - 1.0;
float4 s0 = floor(b0) * 2.0 + 1.0;
float4 s1 = floor(b1) * 2.0 + 1.0;
float4 sh = -step(h, 0.0);
float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
float4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
float3 g0 = float3(a0.xy, h.x);
float3 g1 = float3(a0.zw, h.y);
float3 g2 = float3(a1.xy, h.z);
float3 g3 = float3(a1.zw, h.w);
// Normalise gradients
float4 norm = taylorInvSqrt(float4(dot(g0, g0), dot(g1, g1), dot(g2, g2), dot(g3, g3)));
g0 *= norm.x;
g1 *= norm.y;
g2 *= norm.z;
g3 *= norm.w;
// Compute noise and gradient at P
float4 m = max(0.6 - float4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);
float4 m2 = m * m;
float4 m3 = m2 * m;
float4 m4 = m2 * m2;
float3 grad = -6.0 * m3.x * x0 * dot(x0, g0) + m4.x * g0 +
- 6.0 * m3.y * x1 * dot(x1, g1) + m4.y * g1 +
- 6.0 * m3.z * x2 * dot(x2, g2) + m4.z * g2 +
- 6.0 * m3.w * x3 * dot(x3, g3) + m4.w * g3;
float4 px = float4(dot(x0, g0), dot(x1, g1), dot(x2, g2), dot(x3, g3));
return 42.0 * float4(grad, dot(m4, px));
}
//----------------------------------------------------[1.3] 4D Simplex Noise ----------------------------------------------------
float4 grad4(float j, float4 ip)
{
const float4 ones = float4(1.0, 1.0, 1.0, -1.0);
float4 p, s;
p.xyz = floor(frac(j * ip.xyz) * 7.0) * ip.z - 1.0;
p.w = 1.5 - dot(abs(p.xyz), ones.xyz);
// GLSL: lessThan(x, y) = x < y
// HLSL: 1 - step(y, x) = x < y
p.xyz -= sign(p.xyz) * (p.w < 0);
return p;
}
float snoise(float4 v)
{
const float4 C = float4(
0.138196601125011, // (5 - sqrt(5))/20 G4
0.276393202250021, // 2 * G4
0.414589803375032, // 3 * G4
-0.447213595499958 // -1 + 4 * G4
);
// First corner
float4 i = floor(v +dot(v,0.309016994374947451)); // (sqrt(5) - 1) / 4
float4 x0 = v - i + dot(i, C.xxxx);
// Other corners
// Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)
float4 i0;
float3 isX = step(x0.yzw, x0.xxx);
float3 isYZ = step(x0.zww, x0.yyz);
i0.x = isX.x + isX.y + isX.z;
i0.yzw = 1.0 - isX;
i0.y += isYZ.x + isYZ.y;
i0.zw += 1.0 - isYZ.xy;
i0.z += isYZ.z;
i0.w += 1.0 - isYZ.z;
// i0 now contains the unique values 0,1,2,3 in each channel
float4 i3 = saturate(i0);
float4 i2 = saturate(i0 - 1.0);
float4 i1 = saturate(i0 - 2.0);
// x0 = x0 - 0.0 + 0.0 * C.xxxx
// x1 = x0 - i1 + 1.0 * C.xxxx
// x2 = x0 - i2 + 2.0 * C.xxxx
// x3 = x0 - i3 + 3.0 * C.xxxx
// x4 = x0 - 1.0 + 4.0 * C.xxxx
float4 x1 = x0 - i1 + C.xxxx;
float4 x2 = x0 - i2 + C.yyyy;
float4 x3 = x0 - i3 + C.zzzz;
float4 x4 = x0 + C.wwww;
// Permutations
i = mod289(i);
float j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x);
float4 j1 = permute(permute(permute(permute(i.w + float4(i1.w, i2.w, i3.w, 1.0)) + i.z + float4(i1.z, i2.z, i3.z, 1.0)) + i.y + float4(i1.y, i2.y, i3.y, 1.0)) + i.x + float4(i1.x, i2.x, i3.x, 1.0));
// Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope
// 7*7*6 = 294, which is close to the ring size 17*17 = 289.
const float4 ip = float4(0.003401360544217687075, // 1/294
0.020408163265306122449, // 1/49
0.142857142857142857143, // 1/7
0.0);
float4 p0 = grad4(j0, ip);
float4 p1 = grad4(j1.x, ip);
float4 p2 = grad4(j1.y, ip);
float4 p3 = grad4(j1.z, ip);
float4 p4 = grad4(j1.w, ip);
// Normalise gradients
float4 norm = rsqrt(float4(dot(p0, p0),dot(p1, p1),dot(p2, p2),dot(p3, p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
p4 *= rsqrt(dot(p4, p4));
// Mix contributions from the five corners
float3 m0 = max(0.6 - float3(dot(x0, x0),dot(x1, x1),dot(x2, x2)),0.0);
float2 m1 = max(0.6 - float2(dot(x3, x3),dot(x4, x4)),0.0);
m0 = m0 * m0;
m1 = m1 * m1;
return 49.0 * (dot(m0*m0,float3(dot(p0, x0),dot(p1, x1),dot(p2, x2))) + dot(m1*m1,float2(dot(p3, x3),dot(p4, x4))));
}
//==================================================================================================================================
// 2. Classic Noise
//==================================================================================================================================
//
// GLSL textureless classic 2D noise "cnoise",
// with an RSL-style periodic variant "pnoise".
// Author: Stefan Gustavson (stefan.gustavson@liu.se)
// Version: 2011-08-22
//
// Many thanks to Ian McEwan of Ashima Arts for the
// ideas for permutation and gradient selection.
//
// Copyright (c) 2011 Stefan Gustavson. All rights reserved.
// Distributed under the MIT license. See LICENSE file.
// https://github.com/ashima/webgl-noise
//-------------------------------------------------------[2.1] 2D Classic Noise---------------------------------------------
// Classic Perlin noise
float cnoise(float2 P)
{
float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0);
float4 Pf = frac(P.xyxy) - float4(0.0, 0.0, 1.0, 1.0);
Pi = mod289(Pi); // To avoid truncation effects in permutation
float4 ix = Pi.xzxz;
float4 iy = Pi.yyww;
float4 fx = Pf.xzxz;
float4 fy = Pf.yyww;
float4 i = permute(permute(ix) + iy);
float4 gx = frac(i / 41.0) * 2.0 - 1.0;
float4 gy = abs(gx) - 0.5;
float4 tx = floor(gx + 0.5);
gx = gx - tx;
float2 g00 = float2(gx.x, gy.x);
float2 g10 = float2(gx.y, gy.y);
float2 g01 = float2(gx.z, gy.z);
float2 g11 = float2(gx.w, gy.w);
float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
g00 *= norm.x;
g01 *= norm.y;
g10 *= norm.z;
g11 *= norm.w;
float n00 = dot(g00, float2(fx.x, fy.x));
float n10 = dot(g10, float2(fx.y, fy.y));
float n01 = dot(g01, float2(fx.z, fy.z));
float n11 = dot(g11, float2(fx.w, fy.w));
float2 fade_xy = fade(Pf.xy);
float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x);
float n_xy = lerp(n_x.x, n_x.y, fade_xy.y);
return 2.3 * n_xy;
}
// Classic Perlin noise, periodic variant
float pnoise(float2 P, float2 rep)
{
float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0);
float4 Pf = frac(P.xyxy) - float4(0.0, 0.0, 1.0, 1.0);
Pi = mod(Pi, rep.xyxy); // To create noise with explicit period
Pi = mod289(Pi); // To avoid truncation effects in permutation
float4 ix = Pi.xzxz;
float4 iy = Pi.yyww;
float4 fx = Pf.xzxz;
float4 fy = Pf.yyww;
float4 i = permute(permute(ix) + iy);
float4 gx = frac(i / 41.0) * 2.0 - 1.0;
float4 gy = abs(gx) - 0.5;
float4 tx = floor(gx + 0.5);
gx = gx - tx;
float2 g00 = float2(gx.x, gy.x);
float2 g10 = float2(gx.y, gy.y);
float2 g01 = float2(gx.z, gy.z);
float2 g11 = float2(gx.w, gy.w);
float4 norm = taylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
g00 *= norm.x;
g01 *= norm.y;
g10 *= norm.z;
g11 *= norm.w;
float n00 = dot(g00, float2(fx.x, fy.x));
float n10 = dot(g10, float2(fx.y, fy.y));
float n01 = dot(g01, float2(fx.z, fy.z));
float n11 = dot(g11, float2(fx.w, fy.w));
float2 fade_xy = fade(Pf.xy);
float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x);
float n_xy = lerp(n_x.x, n_x.y, fade_xy.y);
return 2.3 * n_xy;
}
//----------------------------------------------------[2.2] 3D Classic Noise--------------------------------------------------
// Classic Perlin noise
float cnoise(float3 P)
{
float3 Pi0 = floor(P); // Integer part for indexing
float3 Pi1 = Pi0 + (float3)1.0; // Integer part + 1
Pi0 = mod289(Pi0);
Pi1 = mod289(Pi1);
float3 Pf0 = frac(P); // Fractional part for interpolation
float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0
float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
float4 iz0 = (float4)Pi0.z;
float4 iz1 = (float4)Pi1.z;
float4 ixy = permute(permute(ix) + iy);
float4 ixy0 = permute(ixy + iz0);
float4 ixy1 = permute(ixy + iz1);
float4 gx0 = ixy0 / 7.0;
float4 gy0 = frac(floor(gx0) / 7.0) - 0.5;
gx0 = frac(gx0);
float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0);
float4 sz0 = step(gz0, (float4)0.0);
gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5);
gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5);
float4 gx1 = ixy1 / 7.0;
float4 gy1 = frac(floor(gx1) / 7.0) - 0.5;
gx1 = frac(gx1);
float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1);
float4 sz1 = step(gz1, (float4)0.0);
gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5);
gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5);
float3 g000 = float3(gx0.x, gy0.x, gz0.x);
float3 g100 = float3(gx0.y, gy0.y, gz0.y);
float3 g010 = float3(gx0.z, gy0.z, gz0.z);
float3 g110 = float3(gx0.w, gy0.w, gz0.w);
float3 g001 = float3(gx1.x, gy1.x, gz1.x);
float3 g101 = float3(gx1.y, gy1.y, gz1.y);
float3 g011 = float3(gx1.z, gy1.z, gz1.z);
float3 g111 = float3(gx1.w, gy1.w, gz1.w);
float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z));
float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z));
float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z));
float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z));
float n111 = dot(g111, Pf1);
float3 fade_xyz = fade(Pf0);
float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z);
float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}
// Classic Perlin noise, periodic variant
float pnoise(float3 P, float3 rep)
{
float3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
float3 Pi1 = mod(Pi0 + (float3)1.0, rep); // Integer part + 1, mod period
Pi0 = mod289(Pi0);
Pi1 = mod289(Pi1);
float3 Pf0 = frac(P); // Fractional part for interpolation
float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0
float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
float4 iz0 = (float4)Pi0.z;
float4 iz1 = (float4)Pi1.z;
float4 ixy = permute(permute(ix) + iy);
float4 ixy0 = permute(ixy + iz0);
float4 ixy1 = permute(ixy + iz1);
float4 gx0 = ixy0 / 7.0;
float4 gy0 = frac(floor(gx0) / 7.0) - 0.5;
gx0 = frac(gx0);
float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0);
float4 sz0 = step(gz0, (float4)0.0);
gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5);
gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5);
float4 gx1 = ixy1 / 7.0;
float4 gy1 = frac(floor(gx1) / 7.0) - 0.5;
gx1 = frac(gx1);
float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1);
float4 sz1 = step(gz1, (float4)0.0);
gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5);
gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5);
float3 g000 = float3(gx0.x, gy0.x, gz0.x);
float3 g100 = float3(gx0.y, gy0.y, gz0.y);
float3 g010 = float3(gx0.z, gy0.z, gz0.z);
float3 g110 = float3(gx0.w, gy0.w, gz0.w);
float3 g001 = float3(gx1.x, gy1.x, gz1.x);
float3 g101 = float3(gx1.y, gy1.y, gz1.y);
float3 g011 = float3(gx1.z, gy1.z, gz1.z);
float3 g111 = float3(gx1.w, gy1.w, gz1.w);
float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z));
float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z));
float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z));
float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z));
float n111 = dot(g111, Pf1);
float3 fade_xyz = fade(Pf0);
float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z);
float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}
//==================================================================================================================================
// 3. Simplex-like Re-oriented BBC Noise
//==================================================================================================================================
//
// The original shader was created by KdotJPG and released into the public
// domain (Unlicense). Refer to the following GitHub repository for the details
// of the original work.
//
// https://github.com/KdotJPG/New-Simplex-Style-Gradient-Noise
//
float4 bcc4_mod(float4 x, float4 y)
{
return x - y * floor(x / y);
}
// Inspired by Stefan Gustavson's noise
float4 bcc4_permute(float4 t)
{
return t * (t * 34.0 + 133.0);
}
//--------------------------------------------------[3.1] 4-Point BCC Noise-----------------------------------------------
// K.jpg's Smooth Re-oriented 8-Point BCC Noise
// Output: float4(dF/dx, dF/dy, dF/dz, value)
// Gradient set is a normalized expanded rhombic dodecahedron
float3 bcc4_grad(float hash)
{
// Random vertex of a cube, +/- 1 each
float3 cube = frac(floor(hash / float3(1, 2, 4)) * 0.5) * 4 - 1;
// Random edge of the three edges connected to that vertex
// Also a cuboctahedral vertex
// And corresponds to the face of its dual, the rhombic dodecahedron
float3 cuboct = cube;
cuboct *= int3(0, 1, 2) != (int) (hash / 16);
// In a funky way, pick one of the four points on the rhombic face
float type = frac(floor(hash / 8) * 0.5) * 2;
float3 rhomb = (1.0 - type) * cube + type * (cuboct + cross(cube, cuboct));
// Expand it so that the new edges are the same length
// as the existing ones
float3 grad = cuboct * 1.22474487139 + rhomb;
// To make all gradients the same length, we only need to shorten the
// second type of vector. We also put in the whole noise scale constant.
// The compiler should reduce it into the existing floats. I think.
grad *= (1.0 - 0.042942436724648037 * type) * 32.80201376986577;
return grad;
}
// BCC lattice split up into 2 cube lattices
float4 Bcc4NoiseBase(float3 X)
{
// First half-lattice, closest edge
float3 v1 = round(X);
float3 d1 = X - v1;
float3 score1 = abs(d1);
float3 dir1 = max(score1.yzx, score1.zxy) < score1;
float3 v2 = v1 + dir1 * (d1 < 0 ? - 1: 1);
float3 d2 = X - v2;
// Second half-lattice, closest edge
float3 X2 = X + 144.5;
float3 v3 = round(X2);
float3 d3 = X2 - v3;
float3 score2 = abs(d3);
float3 dir2 = max(score2.yzx, score2.zxy) < score2;
float3 v4 = v3 + dir2 * (d3 < 0 ? - 1: 1);
float3 d4 = X2 - v4;
// Gradient hashes for the four points, two from each half-lattice
float4 hashes = bcc4_permute(bcc4_mod(float4(v1.x, v2.x, v3.x, v4.x), 289.0));
hashes = bcc4_permute(bcc4_mod(hashes + float4(v1.y, v2.y, v3.y, v4.y), 289.0));
hashes = bcc4_mod(bcc4_permute(bcc4_mod(hashes + float4(v1.z, v2.z, v3.z, v4.z), 289.0)), 48.0);
// Gradient extrapolations & kernel function
float4 a = max(0.5 - float4(dot(d1, d1), dot(d2, d2), dot(d3, d3), dot(d4, d4)), 0.0);
float4 aa = a * a; float4 aaaa = aa * aa;
float3 g1 = bcc4_grad(hashes.x); float3 g2 = bcc4_grad(hashes.y);
float3 g3 = bcc4_grad(hashes.z); float3 g4 = bcc4_grad(hashes.w);
float4 extrapolations = float4(dot(d1, g1), dot(d2, g2), dot(d3, g3), dot(d4, g4));
// Derivatives of the noise
float3 derivative = -8.0 * mul(aa * a * extrapolations, float4x3(d1, d2, d3, d4))
+ mul(aaaa, float4x3(g1, g2, g3, g4));
// Return it all as a float4
return float4(derivative, dot(aaaa, extrapolations));
}
// Use this if you don't want Z to look different from X and Y
float4 Bcc4NoiseClassic(float3 X)
{
// Rotate around the main diagonal. Not a skew transform.
float4 result = Bcc4NoiseBase(dot(X, 2.0 / 3.0) - X);
return float4(dot(result.xyz, 2.0 / 3.0) - result.xyz, result.w);
}
// Use this if you want to show X and Y in a plane, and use Z for time, etc.
float4 Bcc4NoisePlaneFirst(float3 X)
{
// Rotate so Z points down the main diagonal. Not a skew transform.
float3x3 orthonormalMap = float3x3
(
0.788675134594813, -0.211324865405187, -0.577350269189626,
- 0.211324865405187, 0.788675134594813, -0.577350269189626,
0.577350269189626, 0.577350269189626, 0.577350269189626);
float4 result = Bcc4NoiseBase(mul(X, orthonormalMap));
return float4(mul(orthonormalMap, result.xyz), result.w);
}
//------------------------------------------------[3.2] 8-Point BCC Noise------------------------------------------------------
// K.jpg's Smooth Re-oriented 8-Point BCC Noise
// Output: float4(dF/dx, dF/dy, dF/dz, value)
float4 bcc8_mod(float4 x, float4 y)
{
return x - y * floor(x / y);
}
// Borrowed from Stefan Gustavson's noise code
float4 bcc8_permute(float4 t)
{
return t * (t * 34.0 + 133.0);
}
// Gradient set is a normalized expanded rhombic dodecahedron
float3 bcc8_grad(float hash)
{
// Random vertex of a cube, +/- 1 each
float3 cube = frac(floor(hash / float3(1, 2, 4)) * 0.5) * 4 - 1;
// Random edge of the three edges connected to that vertex
// Also a cuboctahedral vertex
// And corresponds to the face of its dual, the rhombic dodecahedron
float3 cuboct = cube;
cuboct *= int3(0, 1, 2) != (int) (hash / 16);
// In a funky way, pick one of the four points on the rhombic face
float type = frac(floor(hash / 8) * 0.5) * 2;
float3 rhomb = (1.0 - type) * cube + type * (cuboct + cross(cube, cuboct));
// Expand it so that the new edges are the same length
// as the existing ones
float3 grad = cuboct * 1.22474487139 + rhomb;
// To make all gradients the same length, we only need to shorten the
// second type of vector. We also put in the whole noise scale constant.
// The compiler should reduce it into the existing floats. I think.
grad *= (1.0 - 0.042942436724648037 * type) * 3.5946317686139184;
return grad;
}
// BCC lattice split up into 2 cube lattices
float4 Bcc8NoiseBase(float3 X)
{
float3 b = floor(X);
float4 i4 = float4(X - b, 2.5);
// Pick between each pair of oppposite corners in the cube.
float3 v1 = b + floor(dot(i4, .25));
float3 v2 = b + float3(1, 0, 0) + float3(-1, 1, 1) * floor(dot(i4, float4( - .25, .25, .25, .35)));
float3 v3 = b + float3(0, 1, 0) + float3(1, -1, 1) * floor(dot(i4, float4(.25, - .25, .25, .35)));
float3 v4 = b + float3(0, 0, 1) + float3(1, 1, -1) * floor(dot(i4, float4(.25, .25, - .25, .35)));
// Gradient hashes for the four vertices in this half-lattice.
float4 hashes = bcc8_permute(bcc8_mod(float4(v1.x, v2.x, v3.x, v4.x), 289.0));
hashes = bcc8_permute(bcc8_mod(hashes + float4(v1.y, v2.y, v3.y, v4.y), 289.0));
hashes = bcc8_mod(bcc8_permute(bcc8_mod(hashes + float4(v1.z, v2.z, v3.z, v4.z), 289.0)), 48.0);
// Gradient extrapolations & kernel function
float3 d1 = X - v1; float3 d2 = X - v2; float3 d3 = X - v3; float3 d4 = X - v4;
float4 a = max(0.75 - float4(dot(d1, d1), dot(d2, d2), dot(d3, d3), dot(d4, d4)), 0.0);
float4 aa = a * a; float4 aaaa = aa * aa;
float3 g1 = bcc8_grad(hashes.x); float3 g2 = bcc8_grad(hashes.y);
float3 g3 = bcc8_grad(hashes.z); float3 g4 = bcc8_grad(hashes.w);
float4 extrapolations = float4(dot(d1, g1), dot(d2, g2), dot(d3, g3), dot(d4, g4));
// Derivatives of the noise
float3 derivative = -8.0 * mul(aa * a * extrapolations, float4x3(d1, d2, d3, d4))
+ mul(aaaa, float4x3(g1, g2, g3, g4));
// Return it all as a float4
return float4(derivative, dot(aaaa, extrapolations));
}
// Rotates domain, but preserve shape. Hides grid better in cardinal slices.
// Good for texturing 3D objects with lots of flat parts along cardinal planes.
float4 Bcc8NoiseClassic(float3 X)
{
X = dot(X, 2.0 / 3.0) - X;
float4 result = Bcc8NoiseBase(X) + Bcc8NoiseBase(X + 144.5);
return float4(dot(result.xyz, 2.0 / 3.0) - result.xyz, result.w);
}
// Gives X and Y a triangular alignment, and lets Z move up the main diagonal.
// Might be good for terrain, or a time varying X/Y plane. Z repeats.
float4 Bcc8NoisePlaneFirst(float3 X)
{
// Not a skew transform.
float3x3 orthonormalMap = float3x3(
0.788675134594813, -0.211324865405187, -0.577350269189626,
- 0.211324865405187, 0.788675134594813, -0.577350269189626,
0.577350269189626, 0.577350269189626, 0.577350269189626);
X = mul(X, orthonormalMap);
float4 result = Bcc8NoiseBase(X) + Bcc8NoiseBase(X + 144.5);
return float4(mul(orthonormalMap, result.xyz), result.w);
}
#endif

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ad65ce05707bad43a6df888d1a27038
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,466 @@

#include "Sampling.hlsl"
//Always present in every shader
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex); //Present in every shader
TEXTURE2D_SAMPLER2D(_CameraDepthNormalsTexture, sampler_CameraDepthNormalsTexture);
float4 _MainTex_TexelSize;
#define fixed half
#define fixed2 half2
#define fixed3 half3
#define fixed4 half4
#define fixed4x4 half4x4
#define fixed3x3 half3x3
#define fixed2x2 half2x2
#define sampler2D_half sampler2D
#define sampler2D_float sampler2D
#define samplerCUBE_half samplerCUBE
#define samplerCUBE_float samplerCUBE
//------------------------------------------------------------------------------------------------------
// Blend Functions
//------------------------------------------------------------------------------------------------------
half4 BlendOperation_Burn(half4 Base, half4 Blend, half Opacity)
{
half4 Out = 1.0 - (1.0 - Blend) / Base;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Darken(half4 Base, half4 Blend, half Opacity)
{
half4 Out = min(Blend, Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Difference(half4 Base, half4 Blend, half Opacity)
{
half4 Out = abs(Blend - Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Dodge(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base / (1.0 - Blend);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Divide(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base / (Blend + 0.000000000001);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Exclusion(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Blend + Base - (2.0 * Blend * Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_HardLight(half4 Base, half4 Blend, half Opacity)
{
float4 result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
float4 result2 = 2.0 * Base * Blend;
float4 zeroOrOne = step(Blend, 0.5);
half4 Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_HardMix(half4 Base, half4 Blend, half Opacity)
{
half4 Out = step(1 - Base, Blend);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Lighten(half4 Base, half4 Blend, half Opacity)
{
half4 Out = max(Blend, Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_LinearBurn(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base + Blend - 1.0;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_LinearDodge(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base + Blend;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_LinearLight(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Blend < 0.5 ? max(Base + (2 * Blend) - 1, 0): min(Base + 2 * (Blend - 0.5), 1);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_LinearLightAddSub(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Blend + 2.0 * Base - 1.0;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Multiply(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base * Blend;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Negation(half4 Base, half4 Blend, half Opacity)
{
half4 Out = 1.0 - abs(1.0 - Blend - Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Overlay(half4 Base, half4 Blend, half Opacity)
{
half4 result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
half4 result2 = 2.0 * Base * Blend;
half4 zeroOrOne = step(Base, 0.5);
half4 Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_PinLight(half4 Base, half4 Blend, half Opacity)
{
half4 check = step(0.5, Blend);
half4 result1 = check * max(2.0 * (Base - 0.5), Blend);
half4 Out = result1 + (1.0 - check) * min(2.0 * Base, Blend);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Screen(half4 Base, half4 Blend, half Opacity)
{
half4 Out = 1.0 - (1.0 - Blend) * (1.0 - Base);
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_SoftLight(half4 Base, half4 Blend, half Opacity)
{
half4 result1 = 2.0 * Base * Blend + Base * Base * (1.0 - 2.0 * Blend);
half4 result2 = sqrt(Base) * (2.0 * Blend - 1.0) + 2.0 * Base * (1.0 - Blend);
half4 zeroOrOne = step(0.5, Blend);
half4 Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Subtract(half4 Base, half4 Blend, half Opacity)
{
half4 Out = Base - Blend;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_VividLight(half4 Base, half4 Blend, half Opacity)
{
half4 result1 = 1.0 - (1.0 - Blend) / (2.0 * Base);
half4 result2 = Blend / (2.0 * (1.0 - Base));
half4 zeroOrOne = step(0.5, Base);
half4 Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
Out = lerp(Base, Out, Opacity);
return Out;
}
half4 BlendOperation_Overwrite(half4 Base, half4 Blend, half Opacity)
{
half4 Out = lerp(Base, Blend, Opacity);
return Out;
}
//------------------------------------------------------------------------------------------------------
// Generic functions
//------------------------------------------------------------------------------------------------------
float rand(float n)
{
return frac(sin(n) * 13758.5453123 * 0.01);
}
float rand(float2 n)
{
return frac(sin(dot(n, float2(12.9898, 78.233))) * 43758.5453);
}
float2 RotateUV(float2 uv, float rotation)
{
float cosine = cos(rotation);
float sine = sin(rotation);
float2 pivot = float2(0.5, 0.5);
float2 rotator = (mul(uv - pivot, float2x2(cosine, -sine, sine, cosine)) + pivot);
return saturate(rotator);
}
float3 ChromaticAberration(TEXTURE2D_ARGS(tex, samplerTex), float4 texelSize, float2 uv, float amount)
{
float2 direction = normalize((float2(0.5, 0.5) - uv));
float3 distortion = float3(-texelSize.x * amount, 0, texelSize.x * amount);
float red = SAMPLE_TEXTURE2D(tex, samplerTex, uv + direction * distortion.r).r;
float green = SAMPLE_TEXTURE2D(tex, samplerTex, uv + direction * distortion.g).g;
float blue = SAMPLE_TEXTURE2D(tex, samplerTex, uv + direction * distortion.b).b;
return float3(red, green, blue);
}
/*
float3 PositionFromDepth(float depth, float2 uv, float4 inverseViewMatrix) {
float4 clip = float4((uv.xy * 2.0f - 1.0f) * float2(1, -1), 0.0f, 1.0f);
float3 worldDirection = mul(inverseViewMatrix, clip) - _WorldSpaceCameraPos;
float3 worldspace = worldDirection * depth + _WorldSpaceCameraPos;
return float3(frac((worldspace.rgb)) + float3(0, 0, 0.1));
}
*/
// (returns 1.0 when orthographic)
float CheckPerspective(float x)
{
return lerp(x, 1.0, unity_OrthoParams.w);
}
// Reconstruct view-space position from UV and depth.
float3 ReconstructViewPos(float2 uv, float depth)
{
float3 worldPos = float3(0, 0, 0);
worldPos.xy = (uv.xy * 2.0 - 1.0 - float2(unity_CameraProjection._13, unity_CameraProjection._23)) / float2(unity_CameraProjection._11, unity_CameraProjection._22) * CheckPerspective(depth);
worldPos.z = depth;
return worldPos;
}
float2 FisheyeUV(half2 uv, half amount, half zoom)
{
half2 center = uv.xy - half2(0.5, 0.5);
half CdotC = dot(center, center);
half f = 1.0 + CdotC * (amount * sqrt(CdotC));
return f * zoom * center + 0.5;
}
float2 Distort(float2 uv)
{
#if DISTORT
{
uv = (uv - 0.5) * _Distortion_Amount.z + 0.5;
float2 ruv = _Distortion_CenterScale.zw * (uv - 0.5 - _Distortion_CenterScale.xy);
float ru = length(float2(ruv));
UNITY_BRANCH
if (_Distortion_Amount.w > 0.0)
{
float wu = ru * _Distortion_Amount.x;
ru = tan(wu) * (1.0 / (ru * _Distortion_Amount.y));
uv = uv + ruv * (ru - 1.0);
}
else
{
ru = (1.0 / ru) * _Distortion_Amount.x * atan(ru * _Distortion_Amount.y);
uv = uv + ruv * (ru - 1.0);
}
}
#endif
return uv;
}
//----------------------------------------------------------------
// Common vertex functions
//--------------------------------------------------------------
float4 _BlurOffsets;
struct v2fGaussian
{
float4 pos: POSITION;
float2 uv: TEXCOORD0;
float4 uv01: TEXCOORD1;
float4 uv23: TEXCOORD2;
float4 uv45: TEXCOORD3;
};
v2fGaussian VertGaussian(AttributesDefault v)
{
v2fGaussian o;
o.pos = float4(v.vertex.xy, 0, 1);
o.uv.xy = TransformTriangleVertexToUV(o.pos.xy);
#if UNITY_UV_STARTS_AT_TOP
o.uv = o.uv * float2(1.0, -1.0) + float2(0.0, 1.0);
#endif
//UNITY_SINGLE_PASS_STEREO
o.uv = TransformStereoScreenSpaceTex(o.uv, 1.0);
o.uv01 = o.uv.xyxy + _BlurOffsets.xyxy * float4(1, 1, -1, -1);
o.uv23 = o.uv.xyxy + _BlurOffsets.xyxy * float4(1, 1, -1, -1) * 2.0;
o.uv45 = o.uv.xyxy + _BlurOffsets.xyxy * float4(1, 1, -1, -1) * 6.0;
return o;
}
float4 FragBlurBox(VaryingsDefault i): SV_Target
{
return DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, _BlurOffsets.xy).rgba;
}
float4 FragBlurGaussian(v2fGaussian i): SV_Target
{
half4 color = float4(0, 0, 0, 0);
color += 0.40 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
color += 0.15 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv01.xy);
color += 0.15 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv01.zw);
color += 0.10 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv23.xy);
color += 0.10 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv23.zw);
color += 0.05 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv45.xy);
color += 0.05 * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv45.zw);
return color;
}
half simpleNoise(half x, half y, half seed, half phase)
{
half n = x * y * phase * seed;
return fmod(n, 13) * fmod(n, 123);
}
half3 Lut2D(TEXTURE2D_ARGS(tex, samplerTex), float3 uvw, float2 texelSize, half tileAmount)
{
uvw.z *= tileAmount;
float shift = floor(uvw.z);
uvw.xy = uvw.xy * tileAmount * texelSize.xy + texelSize.xy * 0.5;
uvw.x += shift * texelSize.y;
uvw.xyz = lerp(
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy).rgb,
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy + float2(texelSize.y, 0.0)).rgb,
uvw.z - shift
);
return uvw;
}
half3 Lut2D_InvertY(TEXTURE2D_ARGS(tex, samplerTex), float3 uvw, float2 texelSize, half tileAmount)
{
// Strip format where `height = sqrt(width)`
uvw.z *= tileAmount;
float shift = floor(uvw.z);
uvw.xy = uvw.xy * tileAmount * texelSize.xy + texelSize.xy * 0.5;
uvw.x += shift * texelSize.y;
//uvw.y = 1 - uvw.y;
uvw.xyz = lerp(
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy).rgb,
SAMPLE_TEXTURE2D(tex, samplerTex, uvw.xy + float2(texelSize.y, 0.0)).rgb,
uvw.z - shift
);
return uvw;
}
//-------------------------------------------------------------------------------------------
// Lift, Gamma (pre-inverted), Gain tuned for HDR use - best used with the ACES tonemapper as
// negative values will creep in the result
// Expected workspace: ACEScg (linear)
//-------------------------------------------------------------------------------------------
half3 LiftGammaGain_HDR(half3 c, half3 lift, float3 invgamma, half3 gain)
{
c = c * gain + lift;
// ACEScg will output negative values, as clamping to 0 will lose precious information we'll
// mirror the gamma function instead
return FastSign(c) * pow(abs(c), invgamma);
}
half3 Luminance_V1(half3 color)
{
return(color.r * 0.3 + color.g * 0.59 + color.b * 0.11);
}
half Luminance_V2(half3 color)
{
return dot(color, half3(0.222, 0.707, 0.071));
}
half4 LuminanceThreshold(half4 color, half threshold)
{
half br = Max3(color.r, color.g, color.b);
half contrib = max(0, br - threshold);
contrib /= max(br, 0.001);
return color * contrib;
}
float4 GetDepthNormal_ViewSpace(float2 uv)
{
float4 cdn = SAMPLE_TEXTURE2D(_CameraDepthNormalsTexture, sampler_CameraDepthNormalsTexture, uv);
float4 Normal_ViewSpace = float4(DecodeViewNormalStereo(cdn), 1);
return Normal_ViewSpace;
}
float GetSinusoidWave(float len, float pi, float time)
{
float wave = sin(8.0f * pi * len + time);
wave = 0.5 * wave + 0.2;
wave *= wave * wave;
return wave;
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df45a9a1fca2ef24fb63d70aa7e08e9f
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,98 @@
// VR/AR/xR lib
#ifndef UNITY_POSTFX_XRLIB
#define UNITY_POSTFX_XRLIB
#if defined(UNITY_SINGLE_PASS_STEREO)
CBUFFER_START(UnityStereoGlobals)
float4x4 unity_StereoMatrixP[2];
float4x4 unity_StereoMatrixV[2];
float4x4 unity_StereoMatrixInvV[2];
float4x4 unity_StereoMatrixVP[2];
float4x4 unity_StereoCameraProjection[2];
float4x4 unity_StereoCameraInvProjection[2];
float4x4 unity_StereoWorldToCamera[2];
float4x4 unity_StereoCameraToWorld[2];
float3 unity_StereoWorldSpaceCameraPos[2];
float4 unity_StereoScaleOffset[2];
CBUFFER_END
CBUFFER_START(UnityStereoEyeIndex)
int unity_StereoEyeIndex;
CBUFFER_END
#endif
float _RenderViewportScaleFactor;
float2 UnityStereoScreenSpaceUVAdjust(float2 uv, float4 scaleAndOffset)
{
return uv.xy * scaleAndOffset.xy + scaleAndOffset.zw;
}
float4 UnityStereoScreenSpaceUVAdjust(float4 uv, float4 scaleAndOffset)
{
return float4(UnityStereoScreenSpaceUVAdjust(uv.xy, scaleAndOffset), UnityStereoScreenSpaceUVAdjust(uv.zw, scaleAndOffset));
}
float2 UnityStereoClampScaleOffset(float2 uv, float4 scaleAndOffset)
{
return clamp(uv, scaleAndOffset.zw, scaleAndOffset.zw + scaleAndOffset.xy);
}
#if defined(UNITY_SINGLE_PASS_STEREO)
float2 TransformStereoScreenSpaceTex(float2 uv, float w)
{
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
scaleOffset.xy *= _RenderViewportScaleFactor;
return uv.xy * scaleOffset.xy + scaleOffset.zw * w;
}
float2 UnityStereoTransformScreenSpaceTex(float2 uv)
{
return TransformStereoScreenSpaceTex(saturate(uv), 1.0);
}
float4 UnityStereoTransformScreenSpaceTex(float4 uv)
{
return float4(UnityStereoTransformScreenSpaceTex(uv.xy), UnityStereoTransformScreenSpaceTex(uv.zw));
}
float2 UnityStereoClamp(float2 uv)
{
float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
scaleOffset.xy *= _RenderViewportScaleFactor;
return UnityStereoClampScaleOffset(uv, scaleOffset);
}
float4 UnityStereoAdjustedTexelSize(float4 texelSize) // Should take in _MainTex_TexelSize
{
texelSize.x = texelSize.x * 2.0; // texelSize.x = 1/w. For a double-wide texture, the true resolution is given by 2/w.
texelSize.z = texelSize.z * 0.5; // texelSize.z = w. For a double-wide texture, the true size of the eye texture is given by w/2.
return texelSize;
}
#else
float2 TransformStereoScreenSpaceTex(float2 uv, float w)
{
return uv * _RenderViewportScaleFactor;
}
float2 UnityStereoTransformScreenSpaceTex(float2 uv)
{
return TransformStereoScreenSpaceTex(saturate(uv), 1.0);
}
float2 UnityStereoClamp(float2 uv)
{
float4 scaleOffset = float4(_RenderViewportScaleFactor, _RenderViewportScaleFactor, 0.f, 0.f);
return UnityStereoClampScaleOffset(uv, scaleOffset);
}
float4 UnityStereoAdjustedTexelSize(float4 texelSize)
{
return texelSize;
}
#endif
#endif // UNITY_POSTFX_XRLIB

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a9b6f01d1ec2d5e44b05163c02bc9aa4
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: