Skip to content

Commit

Permalink
Wuthering Waves Shader Update
Browse files Browse the repository at this point in the history
- Implemented the Aurora shader feature. This effect was first seen on shorekeeper.

Co-Authored-By: Manashiku <[email protected]>
  • Loading branch information
Melioli and Manashiku committed Jan 1, 2025
1 parent 8b68899 commit 9b37e8b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Shaders/Wuthering Waves/HoyoToonWutheringWaves.shader
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,28 @@ Shader "HoyoToon/Wuthering Waves/Character"
[HideInInspector] end_soundwave ("", Float) = 0

[HideInInspector] end_tacet ("", Float) = 0

[HideInInspector] start_uvwave("Star Aurora", Float) = 0
[Toggle] _UseStarrySky ("Enable Star Aurora", Float) = 0
_AuroraAmount ("Aurora Amount", Float) = 3.0
[HideInInspector] start_secondrgb ("Secondary Diffuse", float) = 0
_Second_RGB ("Secondary Diffuse", 2D) = "white" {}
_Second_NoiseStrength ("Secondary Noise Strength", Float) = 0.15
_Second_Height ("Secondary Height", Float) = -0.4
_Second_HeightRadio ("Secondary Height Ratio", Float) = 0.6
[HideInInspector] end_secondrgb ("", float) = 0
[HideInInspector] start_starrynoise ("Noise", Float) = 0
[Toggle] _UseNoise ("Enable Noise", Float) = 0
_CommonNoiseMap ("Common Noise Map", 2D) = "white" {}
[HideInInspector] end_starrynoise ("", Float) = 0
[HideInInspector] start_wave ("Wave", Float) = 0
_WaveAmount ("Wave Amount", Float) = 0.8
_WaveNormalAmount ("Wave Normal Amount", Float) = 1.2
_WaveSpeed ("Wave Speed", Float) = 0.3
_WaveTiling ("Wave Tiling", Float) = 5.5
[HideInInspector] end_wave ("", Float) = 0

[HideInInspector] end_uvwave("", Float) = 0
[HideInInspector] end_special ("", Float) = 0

[HideInInspector] start_renderingOptions("Rendering Options", Float) = 0
Expand Down
28 changes: 28 additions & 0 deletions Shaders/Wuthering Waves/Include/HoyoToonWutheringWaves-common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -783,4 +783,32 @@ void material_tacet(inout float3 color, in float2 uv)
clip((1-mark) - 0.01f);

color.xyz = lerp(_SDFColor, color.xyz, mark);
}

void aurora_wave(in float2 uv, in float3 pos, in float3 normal, in float3 tangent, in float3 view, in float4 spos, inout float3 color)
{
// get screenspace uvs
float2 ssuv = spos.xy/spos.ww;
ssuv = ssuv * _Second_Height;
// sample noise texture
float noise = _CommonNoiseMap.Sample(sampler_linear_repeat, uv + (_Time.yy * float2(0.f, 0.1f))).y * _Second_NoiseStrength ;
// sample stars and mask
float4 secondary = _Second_RGB.Sample(sampler_linear_repeat, ssuv * (noise * 2.0 - 1.0f));
float mask = _Second_RGB.Sample(sampler_linear_repeat, uv).w;

// Calculate the aurora effect using UVs and normals
float aurora = sin((uv.y) * (5.0f * _WaveTiling) + (_Time.y * (_WaveSpeed * 10.0f))) * 0.5 + 0.5 ;
float auroraFactor = sin(normal.y * normal.z) * -_WaveNormalAmount;
aurora = aurora + auroraFactor;
// modify the aurora
aurora = max(aurora, 0.0f);
aurora = pow(aurora, 1.0f);
aurora = smoothstep(0.5f, 1.0f, aurora);

// calculate color
float3 auroraColor = secondary + pow(color, 1.2f);
auroraColor = auroraColor * (aurora * _AuroraAmount);

// mask and add the auroraColor to the output color
color.xyz = auroraColor * mask + color;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ Texture2D _SDF;
Texture2D _Noise;
Texture2D _Noise02;
Texture2D _ShakeNoise;
Texture2D _Second_RGB;
Texture2D _CommonNoiseMap;
SamplerState sampler_MainTex;
SamplerState sampler_linear_repeat;
SamplerState sampler_linear_clamp;

float4 _CommonNoiseMap_ST;


float4 _EM_TexelSize; // x 1/height y 1/width z height w width

Expand Down Expand Up @@ -210,6 +214,18 @@ float _RimHardness;
float _Metalllic;
float _UsePBR;

// aurora
float _UseStarrySky;
float _AuroraAmount;
float _Second_NoiseStrength;
float _Second_Height;
float _Second_HeightRadio;
float _UseNoise;
float _WaveAmount;
float _WaveNormalAmount;
float _WaveSpeed;
float _WaveTiling;

// debug
float _DebugMode;
float _DebugDiffuse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ fixed4 ps_model (vertex_out i) : SV_Target
#if defined(use_stocking)
}
#endif
if(_UseStarrySky) aurora_wave(uv, i.ws_pos, normal, tangent, view, i.ss_pos, color.xyz);
}
#if defined(is_face)
else if(_MaterialType == 1) // face shading, there isnt
Expand Down

0 comments on commit 9b37e8b

Please sign in to comment.