一些特效
This commit is contained in:
238
Packages/NBPostProcessing/Shader/ColorBlit.shader
Normal file
238
Packages/NBPostProcessing/Shader/ColorBlit.shader
Normal file
@@ -0,0 +1,238 @@
|
||||
Shader "XuanXuan/ColorBlit"
|
||||
{
|
||||
HLSLINCLUDE
|
||||
#pragma target 2.0
|
||||
#pragma editor_sync_compilation
|
||||
#pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY
|
||||
#pragma multi_compile _ BLIT_SINGLE_SLICE
|
||||
// Core.hlsl for XR dependencies
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
ZWrite Off Cull Off
|
||||
Pass
|
||||
{
|
||||
Name "ColorBlitPass0"
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
// #pragma vertex vert
|
||||
// #pragma fragment FragNearest
|
||||
#pragma fragment frag
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
Texture2D _CameraTexture;
|
||||
// Texture2D _CameraTexture;
|
||||
//
|
||||
// struct MyAttributes
|
||||
// {
|
||||
// float4 positionOS : POSITION;
|
||||
// float4 texCoord : TEXCOORD0;
|
||||
// };
|
||||
|
||||
//
|
||||
// Varyings vert(MyAttributes IN)
|
||||
// {
|
||||
// Varyings OUT = (Varyings)0;
|
||||
// OUT.positionCS = float4(IN.positionOS.xyz,1);
|
||||
// half4 clipVertex = OUT.positionCS/OUT.positionCS.w;
|
||||
// OUT.texcoord = ComputeScreenPos(clipVertex);
|
||||
// return OUT;
|
||||
// }
|
||||
|
||||
Varyings vert(Attributes input)//避开官方_BlitScaleBias为0的错误。
|
||||
{
|
||||
Varyings output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
#if SHADER_API_GLES
|
||||
float4 pos = input.positionOS;
|
||||
float2 uv = input.uv;
|
||||
#else
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(input.vertexID);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(input.vertexID);
|
||||
#endif
|
||||
|
||||
output.positionCS = pos;
|
||||
// output.texcoord = uv * _BlitScaleBias.xy + _BlitScaleBias.zw;
|
||||
output.texcoord = uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag (Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
float4 color = SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_LinearRepeat, input.texcoord);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "BoxDownsample"
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
// #pragma vertex Vert
|
||||
#pragma vertex vert
|
||||
#pragma fragment FragBoxDownsample
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
|
||||
Texture2D _CameraTexture;
|
||||
SAMPLER(sampler_CameraTexture);
|
||||
|
||||
#if UNITY_VERSION < 202320
|
||||
float4 _BlitTexture_TexelSize;
|
||||
#endif
|
||||
|
||||
Varyings vert(Attributes input)//避开官方_BlitScaleBias为0的错误。
|
||||
{
|
||||
Varyings output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
#if SHADER_API_GLES
|
||||
float4 pos = input.positionOS;
|
||||
float2 uv = input.uv;
|
||||
#else
|
||||
float4 pos = GetFullScreenTriangleVertexPosition(input.vertexID);
|
||||
float2 uv = GetFullScreenTriangleTexCoord(input.vertexID);
|
||||
#endif
|
||||
|
||||
output.positionCS = pos;
|
||||
// output.texcoord = uv * _BlitScaleBias.xy + _BlitScaleBias.zw;
|
||||
output.texcoord = uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
float _SampleOffset;
|
||||
|
||||
half4 FragBoxDownsample(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(input.texcoord);
|
||||
float4 d = _BlitTexture_TexelSize.xyxy * float4(-_SampleOffset, -_SampleOffset, _SampleOffset,
|
||||
_SampleOffset);
|
||||
|
||||
half4 s;
|
||||
|
||||
s = SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.xy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.zy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.xw);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.zw);
|
||||
|
||||
return s * 0.25h;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "ColorBlitPass_URP_13_1_2_OR_OLDER"
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
// #pragma vertex vert
|
||||
// #pragma fragment FragNearest
|
||||
#pragma fragment frag
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
Texture2D _CameraTexture;
|
||||
// Texture2D _CameraTexture;
|
||||
|
||||
struct MyAttributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
Varyings vert(MyAttributes IN)
|
||||
{
|
||||
Varyings OUT = (Varyings)0;
|
||||
OUT.positionCS = float4(IN.positionOS.xyz,1);
|
||||
half4 clipVertex = OUT.positionCS/OUT.positionCS.w;
|
||||
OUT.texcoord = ComputeScreenPos(clipVertex);
|
||||
return OUT;
|
||||
}
|
||||
half4 frag (Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
float4 color = SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_LinearRepeat, input.texcoord);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "BoxDownsample_URP_13_1_2_OR_OLDER"
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment FragBoxDownsample
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
|
||||
Texture2D _CameraTexture;
|
||||
SAMPLER(sampler_CameraTexture);
|
||||
|
||||
#if UNITY_VERSION < 202320
|
||||
float4 _BlitTexture_TexelSize;
|
||||
#endif
|
||||
|
||||
|
||||
float _SampleOffset;
|
||||
struct MyAttributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings vert(MyAttributes IN)
|
||||
{
|
||||
Varyings OUT = (Varyings)0;
|
||||
OUT.positionCS = float4(IN.positionOS.xyz,1);
|
||||
half4 clipVertex = OUT.positionCS/OUT.positionCS.w;
|
||||
OUT.texcoord = ComputeScreenPos(clipVertex);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 FragBoxDownsample(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(input.texcoord);
|
||||
float4 d = _BlitTexture_TexelSize.xyxy * float4(-_SampleOffset, -_SampleOffset, _SampleOffset,
|
||||
_SampleOffset);
|
||||
|
||||
half4 s;
|
||||
|
||||
s = SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.xy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.zy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.xw);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraTexture, sampler_CameraTexture, uv + d.zw);
|
||||
|
||||
return s * 0.25h;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Packages/NBPostProcessing/Shader/ColorBlit.shader.meta
Normal file
9
Packages/NBPostProcessing/Shader/ColorBlit.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e92fe624a4f13d4eadc7753e236006a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Packages/NBPostProcessing/Shader/ColorBufferBlit.shader
Normal file
105
Packages/NBPostProcessing/Shader/ColorBufferBlit.shader
Normal file
@@ -0,0 +1,105 @@
|
||||
Shader "XuanXuan/ColorBufferBlit"
|
||||
{
|
||||
HLSLINCLUDE
|
||||
#pragma target 2.0
|
||||
#pragma editor_sync_compilation
|
||||
#pragma multi_compile _ DISABLE_TEXTURE2D_X_ARRAY
|
||||
#pragma multi_compile _ BLIT_SINGLE_SLICE
|
||||
// Core.hlsl for XR dependencies
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
ZWrite Off Cull Off
|
||||
Pass
|
||||
{
|
||||
Name "ColorBlitPass0"
|
||||
|
||||
HLSLPROGRAM
|
||||
// #pragma vertex Vert
|
||||
#pragma vertex vert
|
||||
// #pragma fragment FragNearest
|
||||
#pragma fragment frag
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
|
||||
Texture2D _CameraColorTexture;
|
||||
SAMPLER(sampler_CameraColorTexture);
|
||||
|
||||
struct MyAttributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
Varyings vert(MyAttributes IN)
|
||||
{
|
||||
Varyings OUT = (Varyings)0;
|
||||
OUT.positionCS = float4(IN.positionOS.xyz,1);
|
||||
half4 clipVertex = OUT.positionCS/OUT.positionCS.w;
|
||||
OUT.texcoord = ComputeScreenPos(clipVertex);
|
||||
return OUT;
|
||||
}
|
||||
half4 frag (Varyings input) : SV_Target
|
||||
{
|
||||
// UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
float4 color = SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_LinearRepeat, input.texcoord);
|
||||
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "BoxDownsample"
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment FragBoxDownsample
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
|
||||
// Texture2D _CameraTexture;
|
||||
// SAMPLER(sampler_CameraTexture);
|
||||
Texture2D _CameraColorTexture;
|
||||
SAMPLER(sampler_CameraColorTexture);
|
||||
|
||||
#if UNITY_VERSION < 202320
|
||||
float4 _BlitTexture_TexelSize;
|
||||
#endif
|
||||
|
||||
|
||||
float _SampleOffset;
|
||||
|
||||
half4 FragBoxDownsample(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
float2 uv = UnityStereoTransformScreenSpaceTex(input.texcoord);
|
||||
float4 d = _BlitTexture_TexelSize.xyxy * float4(-_SampleOffset, -_SampleOffset, _SampleOffset,
|
||||
_SampleOffset);
|
||||
|
||||
half4 s;
|
||||
|
||||
s = SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + d.xy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + d.zy);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + d.xw);
|
||||
s += SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, uv + d.zw);
|
||||
|
||||
return s * 0.25h;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3150dab783854cd6b791d5db3be4a966
|
||||
timeCreated: 1747582276
|
||||
BIN
Packages/NBPostProcessing/Shader/DistortSpeedNoise.png
Normal file
BIN
Packages/NBPostProcessing/Shader/DistortSpeedNoise.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
156
Packages/NBPostProcessing/Shader/DistortSpeedNoise.png.meta
Normal file
156
Packages/NBPostProcessing/Shader/DistortSpeedNoise.png.meta
Normal file
@@ -0,0 +1,156 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f808d0c8608b954d8f20cb4132c3049
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: iOS
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Packages/NBPostProcessing/Shader/Disturbance.shader
Normal file
113
Packages/NBPostProcessing/Shader/Disturbance.shader
Normal file
@@ -0,0 +1,113 @@
|
||||
Shader "XuanXuan/Disturbance"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MhGroup(Main)]_mainTex("Main", float) = 0
|
||||
[MhTexture(Main)] _MaskMap("Mask Map", 2D) = "white" {}
|
||||
|
||||
[MhTexture(Main,_Strength,on)]_NoiseMap("Noise Map", 2D) = "white"{}
|
||||
[HideInInspector]_Strength("Strength", Range(-0.2,0.2)) =0.1
|
||||
[MhToggleKeyword(Main,_PARTICLE_CUSTOMDATA_ON)]_ParticleCustomDataOn("Particle customData Strength", float) = 0
|
||||
[HideInInspector]_SurfaceType("surfaceType",float)=1
|
||||
[HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
|
||||
}
|
||||
|
||||
// The SubShader block containing the Shader code.
|
||||
SubShader
|
||||
{
|
||||
// SubShader Tags define when and under which conditions a SubShader block or
|
||||
// a pass is executed.
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" "IgnoreProjector" = "True"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
//ZTest Always
|
||||
Cull Off
|
||||
HLSLPROGRAM
|
||||
//gpuInstancing on
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma target 3.5 DOTS_INSTANCING_ON
|
||||
|
||||
#pragma shader_feature_local_fragment _PARTICLE_CUSTOMDATA_ON
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
|
||||
|
||||
// This line defines the name of the vertex shader.
|
||||
#pragma vertex vert
|
||||
// This line defines the name of the fragment shader.
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
|
||||
// This example uses the Attributes structure as an input structure in
|
||||
// the vertex shader.
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
// The positions in this struct must have the SV_POSITION semantic.
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float4 uv :TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
Texture2D _NoiseMap;
|
||||
SAMPLER(sampler_NoiseMap);
|
||||
|
||||
Texture2D _MaskMap;
|
||||
SAMPLER(sampler_MaskMap);
|
||||
float _Strength;
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
float4 _NoiseMap_ST;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
// Declaring the output object (OUT) with the Varyings struct.
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
|
||||
|
||||
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = IN.uv;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
|
||||
half2 screenSpaceUV = IN.positionHCS.xy / _ScaledScreenParams.xy;
|
||||
const half2 noiseUV = screenSpaceUV * _NoiseMap_ST.xy + _NoiseMap_ST.zw;
|
||||
|
||||
half noise = SAMPLE_TEXTURE2D(_NoiseMap, sampler_NoiseMap, noiseUV).r * 2 - 1;
|
||||
half mask = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, IN.uv.xy).r;
|
||||
noise = lerp(0, noise, mask);
|
||||
|
||||
//noise = (noise * _Strength * 5) * 0.5 + 0.5;
|
||||
noise = (noise * _Strength) * 1.25 + 0.5;
|
||||
|
||||
return half4(noise.xxx, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
customEditor "ShaderEditor.MhBaseShaderGUI"
|
||||
}
|
||||
9
Packages/NBPostProcessing/Shader/Disturbance.shader.meta
Normal file
9
Packages/NBPostProcessing/Shader/Disturbance.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b530af6d4d97eb4c8f3725d4cd3e9b8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
Shader "XuanXuan/FullScreenDisturbance"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Strength("Strength", Range(-0.2,0.2)) =0
|
||||
_BaseMap("Base Map", 2D) = "white"
|
||||
//_Mask("Mask", 2D) = "white"
|
||||
|
||||
}
|
||||
|
||||
// The SubShader block containing the Shader code.
|
||||
SubShader
|
||||
{
|
||||
// SubShader Tags define when and under which conditions a SubShader block or
|
||||
// a pass is executed.
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp equal
|
||||
Pass keep
|
||||
}
|
||||
HLSLPROGRAM
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
// This line defines the name of the vertex shader.
|
||||
#pragma vertex vert
|
||||
// This line defines the name of the fragment shader.
|
||||
#pragma fragment frag
|
||||
|
||||
Texture2D _BlitTexture;
|
||||
SAMPLER(sampler_BlitTexture);
|
||||
Texture2D _BaseMap;
|
||||
SAMPLER(sampler_BaseMap);
|
||||
Texture2D _Mask;
|
||||
SAMPLER(simpler_Mask);
|
||||
float _Strength;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
#if UNITY_ANY_INSTANCING_ENABLED
|
||||
uint instanceID : INSTANCEID_SEMANTIC;
|
||||
#endif
|
||||
uint vertexID : VERTEXID_SEMANTIC;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if UNITY_ANY_INSTANCING_ENABLED
|
||||
uint instanceID : CUSTOM_INSTANCE_ID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.position = GetFullScreenTriangleVertexPosition(input.vertexID, UNITY_NEAR_CLIP_VALUE);
|
||||
output.uv = output.position.xy * 0.5 + 0.5;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 frag(Varyings packedInput):SV_TARGET
|
||||
{
|
||||
float2 baseUV = packedInput.position / _ScreenParams.xy;
|
||||
float3 noise = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, baseUV);
|
||||
noise=lerp(0,noise,noise.b);
|
||||
baseUV += noise.xy * _Strength;
|
||||
return SAMPLE_TEXTURE2D(_BlitTexture, sampler_BlitTexture, baseUV);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 126dad763ce350945945655d5c062248
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _BaseMap: {instanceID: 0}
|
||||
- _Mask: {instanceID: 0}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Packages/NBPostProcessing/Shader/HLSL.meta
Normal file
8
Packages/NBPostProcessing/Shader/HLSL.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e73bff430617bbc44ae5b87fb0fa9abf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef POST_PROCESSING_FLAGS
|
||||
#define POST_PROCESSING_FLAGS
|
||||
|
||||
|
||||
#if defined(CUSTOM_POSTPROCESS)
|
||||
uint _NBPostProcessFlags;
|
||||
#define FLAG_BIT_NB_POSTPROCESS_ON (1 << 0)
|
||||
#define FLAG_BIT_DISTORT_SPEED (1 << 1)
|
||||
#define FLAG_BIT_OVERLAYTEXTURE (1 << 2)
|
||||
#define FLAG_BIT_FLASH (1 << 3)
|
||||
#define FLAG_BIT_CHORATICABERRAT (1 << 4)
|
||||
#define FLAG_BIT_RADIALBLUR (1 << 5)
|
||||
#define FLAG_BIT_VIGNETTE (1 << 6)
|
||||
#define FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD (1 << 7)
|
||||
#define FLAG_BIT_OVERLAYTEXTURE_MASKMAP (1 << 8)
|
||||
#define FLAG_BIT_POST_DISTORT_SCREEN_UV (1 << 9)
|
||||
#define FLAG_BIT_RADIALBLUR_BY_DISTORT (1 << 10)
|
||||
#define FLAG_BIT_CHORATICABERRAT_BY_DISTORT (1 << 11)
|
||||
|
||||
|
||||
|
||||
bool CheckLocalFlags(uint bits)
|
||||
{
|
||||
return (_NBPostProcessFlags&bits) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d59b331ef0707e49a98c91244bd0c1a
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
377
Packages/NBPostProcessing/Shader/NBPostProcessUber.shader
Normal file
377
Packages/NBPostProcessing/Shader/NBPostProcessUber.shader
Normal file
@@ -0,0 +1,377 @@
|
||||
Shader "XuanXuan/Postprocess/NBPostProcessUber"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// [MainTexture] _BaseMap("Base Map", 2D) = "white"
|
||||
_SpeedDistortMap("速度径向扭曲贴图", 2D) = "white"
|
||||
_SpeedDistortVec("速度径向 x强度y位置z范围w速度",Vector) = (0,0,0,0)
|
||||
_SpeedDistortVec2("速度径向 x:uvX速度 y:uvY速度",Vector) = (0,0,0,0)
|
||||
|
||||
_TextureOverlay("肌理附加图",2D) = "white"
|
||||
_TextureOverlayIntensity("肌理附加强度",Float) = 0
|
||||
_TextureOverlayAnim("机理图动画",Vector) = (0,0,0,0)
|
||||
_TextureOverlayMask("肌理图蒙板",2D) = "white"
|
||||
|
||||
_InvertIntensity("反向强度",Float) = 0
|
||||
_DeSaturateIntensity("饱和度强度",Float) = 0
|
||||
_Contrast("对比度",Float) = 1
|
||||
_FlashColor("闪颜色", Vector) = (1, 1, 1, 1)
|
||||
|
||||
|
||||
[HideInInspector] _NBPostProcessFlags("_NBPostProcessFlags", Integer) = 0
|
||||
_ChromaticAberrationVector("色散矢量",Vector) = (1,0,0,0)
|
||||
|
||||
_CustomScreenCenter("自定义屏幕中心",Vector) = (0.5,0.5,0,0)
|
||||
_RadialBlurVec("径向模糊矢量 x强度",Vector) = (1,0,0,0)
|
||||
_VignetteVec("暗角矢量 x强度,y圆度,z光滑度",Vector) = (1,0,0,0)
|
||||
|
||||
|
||||
//不知道为什么,这里写成Color老是出错。
|
||||
_VignetteColor("暗角颜色",Vector) = (0.0,0.0,0.0,1.0)
|
||||
|
||||
}
|
||||
|
||||
// The SubShader block containing the Shader code.
|
||||
SubShader
|
||||
{
|
||||
// SubShader Tags define when and under which conditions a SubShader block or
|
||||
// a pass is executed.
|
||||
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
HLSLPROGRAM
|
||||
// This line defines the name of the vertex shader.
|
||||
#pragma vertex vert
|
||||
// This line defines the name of the fragment shader.
|
||||
#pragma fragment frag
|
||||
#define CUSTOM_POSTPROCESS
|
||||
// #define _POLARCOORDINATES
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
#include "HLSL/PostProcessingFlags.hlsl"
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
|
||||
// This example uses the Attributes structure as an input structure in
|
||||
// the vertex shader.
|
||||
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
// The positions in this struct must have the SV_POSITION semantic.
|
||||
float4 positionHCS : SV_POSITION;
|
||||
half2 uv :TEXCOORD0;
|
||||
};
|
||||
|
||||
TEXTURE2D(_ScreenColorCopy1);
|
||||
SAMPLER(_linear_clamp);
|
||||
SAMPLER(sampler_ScreenColorCopy1);
|
||||
|
||||
TEXTURE2D(_DisturbanceMaskTex);
|
||||
SAMPLER(sampler_DisturbanceMaskTex);
|
||||
|
||||
Texture2D _SpeedDistortMap;
|
||||
SAMPLER(sampler_SpeedDistortMap);
|
||||
|
||||
TEXTURE2D(_TextureOverlay);
|
||||
SAMPLER(sampler_TextureOverlay);
|
||||
TEXTURE2D(_TextureOverlayMask);
|
||||
SAMPLER(sampler_TextureOverlayMask);
|
||||
|
||||
#if UNITY_VERSION < 202210
|
||||
SAMPLER(sampler_LinearClamp);
|
||||
#endif
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
float4 _SpeedDistortMap_ST;
|
||||
half4 _SpeedDistortVec;
|
||||
float4 _SpeedDistortVec2;
|
||||
|
||||
half4 _TextureOverlay_ST;
|
||||
half _TextureOverlayIntensity;
|
||||
half4 _TextureOverlayMask_ST;
|
||||
half4 _TextureOverlayAnim;
|
||||
|
||||
half _InvertIntensity;
|
||||
half _DeSaturateIntensity;
|
||||
half _Contrast;
|
||||
half3 _FlashColor;
|
||||
|
||||
half4 _ChromaticAberrationVec;
|
||||
half4 _CustomScreenCenter;
|
||||
half4 _RadialBlurVec;
|
||||
half4 _VignetteVec;
|
||||
half4 _VignetteColor;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
half4 SAMPLE_TEXTURE2D_CHORATICABERRAT(half2 screenUV,half2 distortUV,half2 blurVec,half distToCenter)
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_CHORATICABERRAT_BY_DISTORT))
|
||||
{
|
||||
blurVec = blurVec*0.25*_ChromaticAberrationVec.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
half intensity = 1;
|
||||
half range = _ChromaticAberrationVec.z*0.5f;
|
||||
intensity = NB_Remap(distToCenter,_ChromaticAberrationVec.y-range,_ChromaticAberrationVec.y+range,0,1);
|
||||
blurVec = blurVec*0.25*_ChromaticAberrationVec.x*intensity;
|
||||
}
|
||||
half r = SAMPLE_TEXTURE2D_X(_ScreenColorCopy1, sampler_LinearClamp, screenUV + distortUV ).x;
|
||||
half g = SAMPLE_TEXTURE2D_X(_ScreenColorCopy1, sampler_LinearClamp, blurVec + screenUV + distortUV ).y;
|
||||
half b = SAMPLE_TEXTURE2D_X(_ScreenColorCopy1, sampler_LinearClamp, blurVec * 2.0 + screenUV + distortUV).z;
|
||||
|
||||
half a = dot(blurVec,blurVec)*100000;
|
||||
return half4(r,g,b,a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
// Declaring the output object (OUT) with the Varyings struct.
|
||||
Varyings OUT;
|
||||
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
half4 clipVertex = OUT.positionHCS/OUT.positionHCS.w;
|
||||
OUT.uv = ComputeScreenPos(clipVertex);
|
||||
// Returning the output.
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
half2 screenUV = IN.uv;
|
||||
half2 distortUV = 0;
|
||||
half2 distortUVWithoutIntensity=0;
|
||||
|
||||
half4 color = 0;
|
||||
|
||||
half2 polarCoordinates = 0;
|
||||
|
||||
//half disturbanceMask = (SAMPLE_TEXTURE2D(_DisturbanceMaskTex, _linear_clamp, screenUV)) * 2 - 1 + 0.00392; //8位0.5校准
|
||||
//disturbanceMask *= 0.4;
|
||||
//half2 disturbanceMask = (SAMPLE_TEXTURE2D(_DisturbanceMaskTex, _linear_clamp, screenUV).xy) * 0.8 - 0.398432; //上面两行合并
|
||||
|
||||
half2 disturbanceMask = (SAMPLE_TEXTURE2D(_DisturbanceMaskTex, _linear_clamp, screenUV).xy) * 0.8 - 0.4; //上面两行合并
|
||||
|
||||
|
||||
color.a = SimpleSmoothstep(0,0.01,abs(disturbanceMask.x + disturbanceMask.y));
|
||||
screenUV += disturbanceMask;
|
||||
|
||||
UNITY_BRANCH
|
||||
if (!CheckLocalFlags(FLAG_BIT_NB_POSTPROCESS_ON))
|
||||
{
|
||||
color.rgb = SAMPLE_TEXTURE2D(_ScreenColorCopy1, _linear_clamp, screenUV).rgb;
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if((CheckLocalFlags(FLAG_BIT_DISTORT_SPEED)& (!CheckLocalFlags(FLAG_BIT_POST_DISTORT_SCREEN_UV)))|CheckLocalFlags(FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD))
|
||||
{
|
||||
polarCoordinates= PolarCoordinates(screenUV,_CustomScreenCenter.xy);
|
||||
}
|
||||
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_DISTORT_SPEED))
|
||||
{
|
||||
_SpeedDistortMap_ST.zw += _SpeedDistortVec2.xy * _Time.y;
|
||||
// return half4(polarCoordinates,0,1);
|
||||
half2 distortSpeedUV;
|
||||
if(CheckLocalFlags(FLAG_BIT_POST_DISTORT_SCREEN_UV))
|
||||
{
|
||||
distortSpeedUV = screenUV* _SpeedDistortMap_ST.xy+_SpeedDistortMap_ST.zw;
|
||||
half2 noise = SAMPLE_TEXTURE2D(_SpeedDistortMap,sampler_SpeedDistortMap,distortSpeedUV);
|
||||
noise = noise * 2-1+_SpeedDistortVec.w*0.1;
|
||||
half distortStrength = _SpeedDistortVec.x * 0.2;
|
||||
distortUVWithoutIntensity = noise;
|
||||
distortUV = noise * distortStrength;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
distortSpeedUV = polarCoordinates * _SpeedDistortMap_ST.xy + _SpeedDistortMap_ST.zw;
|
||||
half noise = SAMPLE_TEXTURE2D(_SpeedDistortMap,sampler_SpeedDistortMap,distortSpeedUV);
|
||||
noise *= SimpleSmoothstep(_SpeedDistortVec.y,_SpeedDistortVec.y+_SpeedDistortVec.z,(distortSpeedUV.y - _SpeedDistortMap_ST.w)/_SpeedDistortMap_ST.y);
|
||||
half distortStrength = - _SpeedDistortVec.x * 0.2;
|
||||
distortUV = normalize(screenUV-_CustomScreenCenter.xy)*noise;
|
||||
distortUVWithoutIntensity = distortUV;
|
||||
distortUV *= distortStrength;
|
||||
}
|
||||
|
||||
|
||||
color.a += dot(distortUV,distortUV)*100000;
|
||||
}
|
||||
else
|
||||
{
|
||||
distortUVWithoutIntensity = disturbanceMask;
|
||||
}
|
||||
|
||||
// return half4(((dot(distortUV,distortUV)*100000)).rrr,1);
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_CHORATICABERRAT) || CheckLocalFlags(FLAG_BIT_RADIALBLUR))
|
||||
{
|
||||
float2 blurVec = 0;
|
||||
half dist = 0;
|
||||
|
||||
if(!CheckLocalFlags(FLAG_BIT_CHORATICABERRAT_BY_DISTORT)|!CheckLocalFlags(FLAG_BIT_RADIALBLUR_BY_DISTORT))
|
||||
{
|
||||
blurVec = _CustomScreenCenter.xy - screenUV;
|
||||
dist = dot(blurVec,blurVec)*4;
|
||||
}
|
||||
|
||||
float2 choraticaBerratBlurVec;
|
||||
if(CheckLocalFlags(FLAG_BIT_CHORATICABERRAT))
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_CHORATICABERRAT_BY_DISTORT))
|
||||
{
|
||||
choraticaBerratBlurVec = distortUVWithoutIntensity;
|
||||
}
|
||||
else
|
||||
{
|
||||
choraticaBerratBlurVec = blurVec;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(CheckLocalFlags(FLAG_BIT_RADIALBLUR))
|
||||
{
|
||||
|
||||
float2 radialblurVec;
|
||||
if(CheckLocalFlags(FLAG_BIT_RADIALBLUR_BY_DISTORT))
|
||||
{
|
||||
radialblurVec = distortUVWithoutIntensity*_RadialBlurVec.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
_RadialBlurVec.z *= 0.5;
|
||||
half rangeIntensity = NB_Remap(dist,_RadialBlurVec.y-_RadialBlurVec.z,_RadialBlurVec.y+_RadialBlurVec.z,0,1);
|
||||
rangeIntensity = saturate(rangeIntensity);
|
||||
radialblurVec = blurVec*_RadialBlurVec.x*rangeIntensity;
|
||||
}
|
||||
color.a += dot(blurVec,blurVec)*100;
|
||||
|
||||
half3 acumulateColor = half3(0, 0, 0);
|
||||
|
||||
int iteration = _RadialBlurVec.w;
|
||||
[unroll(12)]
|
||||
for(int i = 0;i<iteration;i++)
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_CHORATICABERRAT))
|
||||
{
|
||||
//sample *3
|
||||
acumulateColor += SAMPLE_TEXTURE2D_CHORATICABERRAT(screenUV,distortUV,choraticaBerratBlurVec,dist);
|
||||
}
|
||||
else
|
||||
{
|
||||
acumulateColor += SAMPLE_TEXTURE2D(_ScreenColorCopy1,_linear_clamp,screenUV + distortUV);
|
||||
}
|
||||
screenUV += radialblurVec;
|
||||
}
|
||||
color.rgb = acumulateColor / iteration;
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 choraticaBerratColor = SAMPLE_TEXTURE2D_CHORATICABERRAT(screenUV,distortUV,choraticaBerratBlurVec,dist);
|
||||
color.rgb = choraticaBerratColor.rgb;
|
||||
color.a += choraticaBerratColor.a;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
color.rgb = SAMPLE_TEXTURE2D(_ScreenColorCopy1,_linear_clamp,screenUV + distortUV);
|
||||
}
|
||||
|
||||
// return half4(color.aaa,1);
|
||||
|
||||
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_OVERLAYTEXTURE))
|
||||
{
|
||||
half2 overlayTexUV;
|
||||
if(CheckLocalFlags(FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD))
|
||||
{
|
||||
overlayTexUV = polarCoordinates;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
overlayTexUV = screenUV;
|
||||
}
|
||||
|
||||
float2 overlayMainTexUV = TRANSFORM_TEX(overlayTexUV,_TextureOverlay);
|
||||
overlayMainTexUV = UVOffsetAnimaiton(overlayMainTexUV,_TextureOverlayAnim.xy,_Time.y);
|
||||
half4 overlayTexSample = SAMPLE_TEXTURE2D(_TextureOverlay,sampler_TextureOverlay,overlayMainTexUV);
|
||||
|
||||
half overlayTexMask = 1;
|
||||
if (CheckLocalFlags(FLAG_BIT_OVERLAYTEXTURE_MASKMAP))
|
||||
{
|
||||
float2 overlayTexMaskUV = TRANSFORM_TEX(overlayTexUV,_TextureOverlayMask);
|
||||
overlayTexMask = SAMPLE_TEXTURE2D(_TextureOverlayMask,sampler_TextureOverlayMask,overlayTexMaskUV);
|
||||
}
|
||||
color.rgb *= lerp(1,overlayTexSample.rgb,overlayTexSample.a*_TextureOverlayIntensity*overlayTexMask);
|
||||
// return half4( lerp(overlayTexSample.rgb,1,overlayTexSample.a*_TextureOverlayIntensity),1);
|
||||
color.a += _TextureOverlayIntensity;
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_FLASH))
|
||||
{
|
||||
color.xyz = RgbToHsv(color.rgb);
|
||||
half3 colorHSV = color.xyz;
|
||||
color.y *= _DeSaturateIntensity;
|
||||
color.rgb = HsvToRgb(color.xyz);
|
||||
|
||||
//因为颜色空间的特殊原因,这里的转换运算可能会造成性能热点,后续考虑优化。
|
||||
half3 invertColor = SRGBToLinear(1- LinearToSRGB(color.xyz));
|
||||
color.rgb = lerp(color.rgb,invertColor,_InvertIntensity);
|
||||
|
||||
half3 endColor = lerp(color,_FlashColor,luminance(color.rgb));
|
||||
color.rgb = lerp(color.rgb,endColor,_InvertIntensity);
|
||||
|
||||
color.rgb = lerp(half3(0.5,0.5,0.5),color.rgb,_Contrast);
|
||||
|
||||
color.a = 1;
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_VIGNETTE))
|
||||
{
|
||||
_VignetteVec.x *= _VignetteColor.a;
|
||||
half2 screenVec = (_CustomScreenCenter.xy - screenUV)*_VignetteVec.x;
|
||||
screenVec.x *= _VignetteVec.y;
|
||||
half2 dist = dot(screenVec,screenVec);
|
||||
dist = saturate(dist);
|
||||
half factor = pow(1-dist,_VignetteVec.z) ;
|
||||
|
||||
color.rgb *= lerp(_VignetteColor,(1.0).xxx,factor);
|
||||
// color.rgb *= saturate(factor);
|
||||
color.a =1;
|
||||
}
|
||||
|
||||
// return half4(_TextureOverlayIntensity.rrr,1);
|
||||
// float finalIntensity = (_SpeedDistortVec.x+ _TextureOverlayIntensity +_InvertIntensity +(1- _DeSaturateIntensity)+_Contrast)*2;
|
||||
// finalIntensity = saturate(finalIntensity);
|
||||
|
||||
// return half4(saturate(color.a).rrr,1);
|
||||
|
||||
return half4(color.rgb,saturate(color.a));
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fd213d22763447c4aa106605e06184e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _SpeedDistortMap: {fileID: 2800000, guid: 7f808d0c8608b954d8f20cb4132c3049, type: 3}
|
||||
- _TextureOverlay: {instanceID: 0}
|
||||
- _TextureOverlayMask: {instanceID: 0}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user