feat(dream): 添加梦境数据溢出与虚焦表现
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: DreamDataOverflow
|
||||
m_Shader: {fileID: 4800000, guid: 6c30d8e44b1b4b4ab9414a90e069f290, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _OverflowChromatic: 0.006
|
||||
- _OverflowExposure: 1.45
|
||||
- _OverflowGlow: 0.65
|
||||
- _OverflowIntensity: 0
|
||||
- _OverflowNoise: 0.08
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db54ed6c97bf4f05a79f53b268f0c52a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,154 @@
|
||||
Shader "AibisDream/DreamDataOverflow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||||
_Color("Tint", Color) = (1,1,1,1)
|
||||
_OverflowIntensity("Overflow Intensity", Range(0, 1)) = 0
|
||||
_OverflowExposure("Overflow Exposure", Range(0, 3)) = 1.45
|
||||
_OverflowGlow("Overflow Glow", Range(0, 2)) = 0.65
|
||||
_OverflowChromatic("Overflow Chromatic", Range(0, 0.04)) = 0.006
|
||||
_OverflowNoise("Overflow Noise", Range(0, 0.5)) = 0.08
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"IgnoreProjector" = "True"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
float4 screenPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
float4 _MainTex_ST;
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _Color;
|
||||
float _OverflowIntensity;
|
||||
float _OverflowExposure;
|
||||
float _OverflowGlow;
|
||||
float _OverflowChromatic;
|
||||
float _OverflowNoise;
|
||||
|
||||
float hash21(float2 value)
|
||||
{
|
||||
value = frac(value * float2(123.34, 456.21));
|
||||
value += dot(value, value + 45.32);
|
||||
return frac(value.x * value.y);
|
||||
}
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionHCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||
output.color = input.color * _Color;
|
||||
output.screenPosition = ComputeScreenPos(output.positionHCS);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 SampleSprite(float2 uv)
|
||||
{
|
||||
return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
float intensity = saturate(_OverflowIntensity);
|
||||
float pulse = 0.92 + sin(_Time.y * 17.0 + input.uv.y * 23.0) * 0.08;
|
||||
float activeIntensity = saturate(intensity * pulse);
|
||||
|
||||
float2 radial = input.uv - 0.5;
|
||||
float radialLength = max(length(radial), 0.001);
|
||||
float2 chromaticDirection = radial / radialLength;
|
||||
float chromaticOffset = _OverflowChromatic * activeIntensity;
|
||||
|
||||
half4 center = SampleSprite(input.uv);
|
||||
half red = SampleSprite(input.uv + chromaticDirection * chromaticOffset).r;
|
||||
half blue = SampleSprite(input.uv - chromaticDirection * chromaticOffset).b;
|
||||
half3 chromatic = half3(red, center.g, blue);
|
||||
|
||||
float2 texel = _MainTex_TexelSize.xy * lerp(1.5, 7.0, activeIntensity);
|
||||
half4 blur = center * 0.2;
|
||||
blur += SampleSprite(input.uv + float2(texel.x, 0)) * 0.1;
|
||||
blur += SampleSprite(input.uv - float2(texel.x, 0)) * 0.1;
|
||||
blur += SampleSprite(input.uv + float2(0, texel.y)) * 0.1;
|
||||
blur += SampleSprite(input.uv - float2(0, texel.y)) * 0.1;
|
||||
blur += SampleSprite(input.uv + texel) * 0.1;
|
||||
blur += SampleSprite(input.uv - texel) * 0.1;
|
||||
blur += SampleSprite(input.uv + float2(texel.x, -texel.y)) * 0.1;
|
||||
blur += SampleSprite(input.uv + float2(-texel.x, texel.y)) * 0.1;
|
||||
|
||||
half luminance = dot(chromatic, half3(0.2126, 0.7152, 0.0722));
|
||||
half glowLuminance = dot(blur.rgb, half3(0.2126, 0.7152, 0.0722));
|
||||
half whiteAmount = saturate(activeIntensity * (_OverflowExposure * 0.38 + luminance * 0.8));
|
||||
half3 exposed = lerp(chromatic, half3(1, 1, 1), whiteAmount);
|
||||
exposed += blur.rgb * glowLuminance * _OverflowGlow * activeIntensity;
|
||||
|
||||
float2 screenUv = input.screenPosition.xy / max(input.screenPosition.w, 0.0001);
|
||||
float noiseSeed = floor(_Time.y * 24.0);
|
||||
float noise = hash21(floor(screenUv * _ScreenParams.xy * 0.32) + noiseSeed);
|
||||
float speck = smoothstep(0.82, 1.0, noise) * _OverflowNoise * activeIntensity;
|
||||
float scan = sin((screenUv.y * _ScreenParams.y + _Time.y * 90.0) * 0.12) * 0.5 + 0.5;
|
||||
exposed += speck * lerp(0.55, 1.0, scan);
|
||||
|
||||
half4 result;
|
||||
result.rgb = exposed * input.color.rgb;
|
||||
result.a = max(center.a, blur.a * activeIntensity * _OverflowGlow * 0.45) * input.color.a;
|
||||
clip(result.a - 0.001);
|
||||
return result;
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DreamDataOverflow2D"
|
||||
Tags { "LightMode" = "Universal2D" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DreamDataOverflowUnlit"
|
||||
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Sprites/Default"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c30d8e44b1b4b4ab9414a90e069f290
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user