Update
This commit is contained in:
70
Assets/Shaders/SukunaDistortionTrail.shader
Normal file
70
Assets/Shaders/SukunaDistortionTrail.shader
Normal file
@@ -0,0 +1,70 @@
|
||||
Shader "Sukuna/DistortionTrail"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_DistortionStrength("Distortion Strength", Range(0, 1)) = 0.5
|
||||
_DistortionMap("Distortion Map", 2D) = "bump" {}
|
||||
_WidthMask("Width Mask", Range(0, 1)) = 0.5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR; // Sử dụng để lấy Alpha từ Trail Renderer
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float _DistortionStrength;
|
||||
sampler2D _DistortionMap;
|
||||
float _WidthMask;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
output.screenPos = ComputeScreenPos(output.positionCS);
|
||||
output.color = input.color;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
// Mask cho trail: mờ ở 2 cạnh và mờ dần theo chiều dài
|
||||
float mask = (1.0 - abs(input.uv.y - 0.5) * 2.0) * input.uv.x * input.color.a;
|
||||
|
||||
float2 noise = tex2D(_DistortionMap, input.uv * 2.0 + _Time.y).rg * 2.0 - 1.0;
|
||||
float2 screenUV = input.screenPos.xy / input.screenPos.w;
|
||||
float2 distortedUV = screenUV + noise * _DistortionStrength * 0.1 * mask;
|
||||
|
||||
float3 background = SampleSceneColor(distortedUV);
|
||||
return float4(background, mask);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Shaders/SukunaDistortionTrail.shader.meta
Normal file
9
Assets/Shaders/SukunaDistortionTrail.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 801e3895bfaae0d4db86e44c9ac51a19
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/Shaders/SukunaProjectile.shader
Normal file
79
Assets/Shaders/SukunaProjectile.shader
Normal file
@@ -0,0 +1,79 @@
|
||||
Shader "Sukuna/ProjectileSlash"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Colors)]
|
||||
[HDR] _MainColor("Core Color", Color) = (0, 0, 0, 1)
|
||||
[HDR] _EdgeColor("Edge Glow", Color) = (10, 0, 0, 1)
|
||||
_EdgeWidth("Edge Width", Range(0, 1)) = 0.3
|
||||
|
||||
[Header(Movement)]
|
||||
_FlowSpeed("Flow Speed", Float) = 2.0
|
||||
_NoiseMap("Noise Map", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Blend SrcAlpha One
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 _MainColor;
|
||||
float4 _EdgeColor;
|
||||
float _EdgeWidth;
|
||||
float _FlowSpeed;
|
||||
sampler2D _NoiseMap;
|
||||
float4 _NoiseMap_ST;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
float x = input.uv.x;
|
||||
float y = input.uv.y;
|
||||
|
||||
// Shape: Nhọn ở đầu (x=1), phình ở giữa
|
||||
float shape = (1.0 - abs(y * 2.0 - 1.0)) * pow(x, 2.0);
|
||||
|
||||
// Hiệu ứng "cuộn" bên trong lưỡi đao
|
||||
float2 noiseUV = input.uv * _NoiseMap_ST.xy + _NoiseMap_ST.zw;
|
||||
noiseUV.x -= _Time.y * _FlowSpeed;
|
||||
float noise = tex2D(_NoiseMap, noiseUV).r;
|
||||
|
||||
float4 finalColor = lerp(_MainColor, _EdgeColor, smoothstep(1.0 - _EdgeWidth, 1.0, shape * noise));
|
||||
finalColor.a = shape;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Shaders/SukunaProjectile.shader.meta
Normal file
9
Assets/Shaders/SukunaProjectile.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 809d8f4413b92324f8e2226672b86bb6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
108
Assets/Shaders/SukunaSlash.shader
Normal file
108
Assets/Shaders/SukunaSlash.shader
Normal file
@@ -0,0 +1,108 @@
|
||||
Shader "Sukuna/DismantleSlash_Advanced"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Colors)]
|
||||
[HDR] _MainColor("Core Color (Black/Dark)", Color) = (0, 0, 0, 1)
|
||||
[HDR] _EdgeColor("Edge Glow Color", Color) = (10, 0, 0, 1) // Tăng cường độ mặc định
|
||||
_EdgeWidth("Edge Width", Range(0, 1)) = 0.3
|
||||
|
||||
[Header(Distortion Settings)]
|
||||
_DistortionStrength("Distortion Strength", Range(0, 2)) = 0.5
|
||||
_DistortionWidth("Distortion Area Width", Range(0, 2)) = 1.0
|
||||
_DistortionMap("Distortion Noise Map", 2D) = "bump" {}
|
||||
|
||||
[Header(Animation)]
|
||||
_Dissolve("Dissolve", Range(0, 1)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" "RenderPipeline" = "UniversalPipeline" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "SlashPass"
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 _MainColor;
|
||||
float4 _EdgeColor;
|
||||
float _EdgeWidth;
|
||||
float _DistortionStrength;
|
||||
float _DistortionWidth;
|
||||
float _Dissolve;
|
||||
sampler2D _DistortionMap;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
output.screenPos = ComputeScreenPos(output.positionCS);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
float x = input.uv.x;
|
||||
float y = input.uv.y;
|
||||
|
||||
// Shape Mask (Hình nhát chém từ UV)
|
||||
float lengthMask = 1.0 - pow(abs(x * 2.0 - 1.0), 4.0);
|
||||
float widthMask = 1.0 - abs(y * 2.0 - 1.0);
|
||||
float shape = saturate(widthMask * lengthMask);
|
||||
|
||||
// Dissolve Mask
|
||||
float alphaMask = saturate(shape - _Dissolve);
|
||||
if (alphaMask <= 0) discard;
|
||||
|
||||
// --- DISTORTION CALCULATION ---
|
||||
// Tạo một mask riêng cho Distortion, rộng hơn vệt chém chính
|
||||
float distortionMask = saturate(widthMask * lengthMask * _DistortionWidth);
|
||||
float2 noise = tex2D(_DistortionMap, input.uv * 2.0).rg * 2.0 - 1.0;
|
||||
float2 screenUV = input.screenPos.xy / input.screenPos.w;
|
||||
|
||||
// Chỉ làm cong vùng xung quanh, giảm dần về 0 ở trung tâm vệt chém (để lõi không bị méo)
|
||||
// Chúng ta dùng (1 - edgeMask) để Distortion mạnh ở rìa và yếu ở giữa
|
||||
float centerProtection = 1.0 - smoothstep(0.8, 1.0, shape);
|
||||
float2 distortedScreenUV = screenUV + noise * _DistortionStrength * 0.05 * distortionMask * centerProtection;
|
||||
|
||||
float3 background = SampleSceneColor(distortedScreenUV);
|
||||
|
||||
// --- COLOR CALCULATION ---
|
||||
// Đen ở giữa, Đỏ ở viền
|
||||
float edgeLerp = smoothstep(1.0 - _EdgeWidth, 1.0, shape);
|
||||
float4 finalColor = lerp(_MainColor, _EdgeColor, edgeLerp);
|
||||
|
||||
// Trộn với background
|
||||
finalColor.rgb = lerp(background, finalColor.rgb, alphaMask);
|
||||
finalColor.a = alphaMask;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Shaders/SukunaSlash.shader.meta
Normal file
9
Assets/Shaders/SukunaSlash.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2b454918213cc047b8ef9b915dc25cd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user