Feat - Add Loading menju
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
%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: GAME_StylizedSky
|
||||
m_Shader: {fileID: 4800000, guid: 80b7948853269e541b4cabcab12ee2ec, 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: []
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _CloudCoverage: 0.5
|
||||
- _CloudScale: 1.2
|
||||
- _CloudSoftness: 0.2
|
||||
- _CloudSpeed: 0.01
|
||||
- _Exposure: 1
|
||||
- _HorizonSharpness: 2.2
|
||||
- _ShootingStarRate: 0.06
|
||||
- _StarDensity: 0.04
|
||||
- _StarTwinkleSpeed: 2
|
||||
- _SunGlowSize: 64
|
||||
- _SunGlowStrength: 1
|
||||
- _SunSize: 0.03
|
||||
m_Colors:
|
||||
- _CloudColor: {r: 1, g: 0.98, b: 0.95, a: 1}
|
||||
- _CloudShadowColor: {r: 0.55, g: 0.6, b: 0.72, a: 1}
|
||||
- _CloudWindDir: {r: 1, g: 0.3, b: 0, a: 0}
|
||||
- _DayHorizon: {r: 0.62, g: 0.78, b: 0.92, a: 1}
|
||||
- _DayZenith: {r: 0.18, g: 0.42, b: 0.78, a: 1}
|
||||
- _NightHorizon: {r: 0.04, g: 0.06, b: 0.12, a: 1}
|
||||
- _NightZenith: {r: 0.01, g: 0.02, b: 0.06, a: 1}
|
||||
- _ShootingStarColor: {r: 1, g: 1, b: 0.9, a: 1}
|
||||
- _SunColor: {r: 1, g: 0.95, b: 0.85, a: 1}
|
||||
- _SunGlowColor: {r: 1, g: 0.7, b: 0.4, a: 1}
|
||||
- _TwilightColor: {r: 0.95, g: 0.45, b: 0.25, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71ef3332edd1b5e46a827cfbf6f52ac2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,208 @@
|
||||
#ifndef SKY_CORE_INCLUDED
|
||||
#define SKY_CORE_INCLUDED
|
||||
|
||||
// =====================================================================================
|
||||
// Sky Core - logique du ciel stylisé PARTAGÉE (skybox procédurale).
|
||||
// Pas de CBUFFER ici : que des fonctions pures + les globals poussés par C#.
|
||||
// À inclure APRÈS Core.hlsl. Réutilise le bruit de SeasonCore.hlsl.
|
||||
//
|
||||
// Tout le ciel est une fonction pure de _TimeOfDay (0..1, minuit -> minuit), donc deux
|
||||
// clients qui partagent la même valeur de temps voient exactement le même ciel.
|
||||
// =====================================================================================
|
||||
|
||||
#include "SeasonCore.hlsl"
|
||||
|
||||
// Heure du jour 0..1 (0 = minuit, 0.25 = aube, 0.5 = midi, 0.75 = crépuscule).
|
||||
// Poussée par le SkyTimeManager via Shader.SetGlobalFloat("_TimeOfDay", ...).
|
||||
float _TimeOfDay;
|
||||
|
||||
// Direction MONDE du soleil (vecteur unitaire pointant DEPUIS la surface VERS le soleil).
|
||||
// Poussée par le SkyTimeManager (-sunLight.forward) pour que le disque solaire colle
|
||||
// exactement à la lumière directionnelle qui éclaire la scène.
|
||||
float3 _SunDirection;
|
||||
|
||||
// Temps continu SYNCHRONISÉ en secondes (écoulé depuis l'époque serveur), poussé par le
|
||||
// SkyTimeManager. On l'utilise pour TOUTE l'animation (nuages, scintillement, étoiles
|
||||
// filantes) au lieu de _Time.y, qui est local à chaque machine et désynchroniserait les
|
||||
// évènements visibles comme les étoiles filantes entre les joueurs.
|
||||
float _SkyTime;
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Facteurs temporels dérivés de _TimeOfDay.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// Hauteur du soleil [-1..1] : 1 au zénith, 0 à l'horizon, négatif sous l'horizon (nuit).
|
||||
float SkySunHeight()
|
||||
{
|
||||
return _SunDirection.y;
|
||||
}
|
||||
|
||||
// Poids de la nuit 0..1 : 0 en plein jour, 1 quand le soleil est bien sous l'horizon.
|
||||
float SkyNightFactor()
|
||||
{
|
||||
return saturate(-SkySunHeight() * 4.0 + 0.15);
|
||||
}
|
||||
|
||||
// Poids du crépuscule/aube 0..1 : pic quand le soleil frôle l'horizon (teintes chaudes).
|
||||
float SkyTwilightFactor()
|
||||
{
|
||||
float h = SkySunHeight();
|
||||
return saturate(1.0 - abs(h) * 6.0);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Dégradé de fond horizon -> zénith, teinté par l'heure du jour.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// Mélange les couleurs zénith/horizon selon l'élévation de la vue, puis bascule entre
|
||||
// palette jour, palette crépuscule (chaude) et palette nuit (sombre/bleutée) selon le soleil.
|
||||
float3 SkyGradient(float3 viewDir,
|
||||
float3 dayZenith, float3 dayHorizon,
|
||||
float3 nightZenith, float3 nightHorizon,
|
||||
float3 twilightColor, float horizonSharpness)
|
||||
{
|
||||
float up = saturate(viewDir.y);
|
||||
float t = pow(1.0 - up, max(horizonSharpness, 0.001));
|
||||
|
||||
float3 dayCol = lerp(dayZenith, dayHorizon, t);
|
||||
float3 nightCol = lerp(nightZenith, nightHorizon, t);
|
||||
|
||||
float night = SkyNightFactor();
|
||||
float twilight = SkyTwilightFactor();
|
||||
|
||||
float3 col = lerp(dayCol, nightCol, night);
|
||||
// Le crépuscule rougeoie surtout près de l'horizon, du côté du soleil.
|
||||
float sunSide = saturate(dot(normalize(viewDir.xz + 1e-4), normalize(_SunDirection.xz + 1e-4)) * 0.5 + 0.5);
|
||||
col = lerp(col, twilightColor, twilight * t * sunSide);
|
||||
return col;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Soleil : disque net + halo doux. Disparaît proprement sous l'horizon.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// Disque solaire dur (smoothstep sur l'angle vue/soleil) qui s'éteint quand le soleil
|
||||
// passe sous l'horizon, pour ne pas laisser un disque flotter la nuit.
|
||||
float3 SunDisk(float3 viewDir, float3 sunColor, float sunSize)
|
||||
{
|
||||
float d = dot(viewDir, _SunDirection);
|
||||
float disk = smoothstep(1.0 - sunSize, 1.0 - sunSize * 0.5, d);
|
||||
float horizonFade = saturate(SkySunHeight() * 8.0 + 0.2);
|
||||
return sunColor * disk * horizonFade;
|
||||
}
|
||||
|
||||
// Halo radial autour du soleil, plus large et plus doux que le disque.
|
||||
float3 SunGlow(float3 viewDir, float3 glowColor, float glowSize, float glowStrength)
|
||||
{
|
||||
float d = dot(viewDir, _SunDirection);
|
||||
float glow = pow(saturate(d), max(glowSize, 0.001));
|
||||
float horizonFade = saturate(SkySunHeight() * 6.0 + 0.3);
|
||||
return glowColor * glow * glowStrength * horizonFade;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Nuages procéduraux : FBM sur le gradient noise, projeté sur la voûte, défilant.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// FBM (somme d'octaves de SeasonGradientNoise) -> densité de nuage 0..1.
|
||||
float SkyFbm(float2 uv)
|
||||
{
|
||||
float sum = 0.0;
|
||||
float amp = 0.5;
|
||||
float freq = 1.0;
|
||||
[unroll]
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
sum += SeasonGradientNoise(uv * freq) * amp;
|
||||
freq *= 2.0;
|
||||
amp *= 0.5;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
// Projette la direction de vue sur un plan "voûte céleste", anime le défilement avec le
|
||||
// temps et éclaire le nuage par la direction du soleil : le bord face au soleil est lumineux,
|
||||
// le ventre du nuage reste sombre. Renvoie rgb prémultiplié + couverture dans .a.
|
||||
float4 Clouds(float3 viewDir, float time,
|
||||
float3 cloudColor, float3 cloudShadowColor,
|
||||
float coverage, float softness, float scale, float2 windDir)
|
||||
{
|
||||
// Au-dessous de l'horizon : pas de nuages.
|
||||
float aboveHorizon = saturate(viewDir.y * 4.0);
|
||||
if (aboveHorizon <= 0.0) return float4(0, 0, 0, 0);
|
||||
|
||||
// Projection planaire : on divise par y pour étirer vers l'horizon (effet de voûte).
|
||||
float2 uv = viewDir.xz / (viewDir.y + 0.15) * scale;
|
||||
uv += windDir * time;
|
||||
|
||||
float density = SkyFbm(uv);
|
||||
float clouds = smoothstep(coverage, coverage + softness, density);
|
||||
|
||||
// Éclairage : décale l'échantillon vers le soleil pour estimer l'épaisseur traversée.
|
||||
float2 lightOffset = _SunDirection.xz * 0.15 * scale;
|
||||
float densityToward = SkyFbm(uv - lightOffset);
|
||||
float lit = saturate((density - densityToward) * 3.0 + 0.5);
|
||||
|
||||
float3 col = lerp(cloudShadowColor, cloudColor, lit);
|
||||
// La nuit, les nuages s'assombrissent (gardent juste un reste de lune/ciel).
|
||||
col *= lerp(1.0, 0.25, SkyNightFactor());
|
||||
|
||||
float alpha = clouds * aboveHorizon;
|
||||
return float4(col * alpha, alpha);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Étoiles : champ haché seuillé, apparaissant la nuit avec un léger scintillement.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// Points épars (hash sur une grille fine de la direction de vue) qui ne s'allument que
|
||||
// la nuit (nightFactor) et scintillent doucement via le temps.
|
||||
float3 Stars(float3 viewDir, float density, float twinkleSpeed, float time)
|
||||
{
|
||||
float aboveHorizon = saturate(viewDir.y * 3.0);
|
||||
if (aboveHorizon <= 0.0) return float3(0, 0, 0);
|
||||
|
||||
float2 uv = viewDir.xz / (viewDir.y + 0.2);
|
||||
float2 cell = floor(uv * 120.0);
|
||||
float2 h = SeasonHash22(cell) * 0.5 + 0.5;
|
||||
|
||||
float star = step(1.0 - density, h.x);
|
||||
float twinkle = 0.6 + 0.4 * sin(time * twinkleSpeed + h.y * 6.2831);
|
||||
|
||||
return star * twinkle * aboveHorizon * SkyNightFactor();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Étoiles filantes : traînées procédurales animées, rares, uniquement la nuit.
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
// Génère des stries fines qui balaient le ciel. Chaque "fenêtre temporelle" tire une
|
||||
// position/direction hachée ; la strie n'est visible qu'une fraction de la fenêtre, ce qui
|
||||
// rend l'évènement rare et déterministe (donc identique sur tous les clients).
|
||||
float3 ShootingStars(float3 viewDir, float time, float3 color, float rate)
|
||||
{
|
||||
float aboveHorizon = saturate(viewDir.y * 2.0);
|
||||
if (aboveHorizon <= 0.0) return float3(0, 0, 0);
|
||||
|
||||
float window = floor(time * rate);
|
||||
float local = frac(time * rate);
|
||||
|
||||
float2 seed = SeasonHash22(float2(window, 17.0)) * 0.5 + 0.5;
|
||||
float2 dir = normalize(SeasonHash22(float2(window, 91.0)));
|
||||
|
||||
float2 uv = viewDir.xz / (viewDir.y + 0.2);
|
||||
float2 start = (seed - 0.5) * 4.0;
|
||||
float2 head = start + dir * (local * 6.0 - 1.0);
|
||||
|
||||
// Distance perpendiculaire à la traînée -> finesse de la strie.
|
||||
float2 rel = uv - head;
|
||||
float along = dot(rel, dir);
|
||||
float perp = length(rel - dir * along);
|
||||
|
||||
float streak = smoothstep(0.04, 0.0, perp) * smoothstep(0.0, -0.6, along) * smoothstep(0.6, 0.0, -along);
|
||||
float life = smoothstep(0.0, 0.1, local) * smoothstep(1.0, 0.4, local);
|
||||
|
||||
return color * streak * life * aboveHorizon * SkyNightFactor();
|
||||
}
|
||||
|
||||
#endif // SKY_CORE_INCLUDED
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1b2c3d4e5f607182930a4b5c6d7e8f9
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,166 @@
|
||||
Shader "GAME/StylizedSky"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Sky Gradient Day)][Space]
|
||||
[HDR] _DayZenith("Day Zenith", Color) = (0.18,0.42,0.78,1)
|
||||
[HDR] _DayHorizon("Day Horizon", Color) = (0.62,0.78,0.92,1)
|
||||
|
||||
[Header(Sky Gradient Night)][Space]
|
||||
[HDR] _NightZenith("Night Zenith", Color) = (0.01,0.02,0.06,1)
|
||||
[HDR] _NightHorizon("Night Horizon", Color) = (0.04,0.06,0.12,1)
|
||||
|
||||
[Header(Twilight)][Space]
|
||||
[HDR] _TwilightColor("Twilight Tint (dawn/dusk)", Color) = (0.95,0.45,0.25,1)
|
||||
_HorizonSharpness("Horizon Sharpness", Range(0.2,6)) = 2.2
|
||||
|
||||
[Header(Sun)][Space]
|
||||
[HDR] _SunColor("Sun Color", Color) = (1.0,0.95,0.85,1)
|
||||
_SunSize("Sun Size", Range(0.0005,0.2)) = 0.03
|
||||
[HDR] _SunGlowColor("Sun Glow Color", Color) = (1.0,0.7,0.4,1)
|
||||
_SunGlowSize("Sun Glow Falloff", Range(1,512)) = 64
|
||||
_SunGlowStrength("Sun Glow Strength", Range(0,4)) = 1.0
|
||||
|
||||
[Header(Clouds)][Space]
|
||||
[HDR] _CloudColor("Cloud Color (lit)", Color) = (1.0,0.98,0.95,1)
|
||||
[HDR] _CloudShadowColor("Cloud Color (shadow)", Color) = (0.55,0.6,0.72,1)
|
||||
_CloudCoverage("Cloud Coverage", Range(0,1)) = 0.5
|
||||
_CloudSoftness("Cloud Edge Softness", Range(0.01,0.6)) = 0.2
|
||||
_CloudScale("Cloud Scale", Range(0.2,4)) = 1.2
|
||||
_CloudSpeed("Cloud Speed", Range(0,0.2)) = 0.01
|
||||
_CloudWindDir("Cloud Wind Dir (xy)", Vector) = (1,0.3,0,0)
|
||||
|
||||
[Header(Stars)][Space]
|
||||
_StarDensity("Star Density", Range(0,0.2)) = 0.04
|
||||
_StarTwinkleSpeed("Star Twinkle Speed", Range(0,8)) = 2.0
|
||||
|
||||
[Header(Shooting Stars)][Space]
|
||||
[HDR] _ShootingStarColor("Shooting Star Color", Color) = (1,1,0.9,1)
|
||||
_ShootingStarRate("Shooting Star Rate", Range(0.01,0.5)) = 0.06
|
||||
|
||||
[Header(Exposure)][Space]
|
||||
_Exposure("Exposure", Range(0,4)) = 1.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
// =================================================================================
|
||||
// Skybox (rendu par RenderSettings.skybox via le pass DrawSkybox d'URP)
|
||||
// =================================================================================
|
||||
Pass
|
||||
{
|
||||
Name "StylizedSky"
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex SkyVertex
|
||||
#pragma fragment SkyFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "SkyCore.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
half4 _DayZenith;
|
||||
half4 _DayHorizon;
|
||||
half4 _NightZenith;
|
||||
half4 _NightHorizon;
|
||||
half4 _TwilightColor;
|
||||
float _HorizonSharpness;
|
||||
|
||||
half4 _SunColor;
|
||||
float _SunSize;
|
||||
half4 _SunGlowColor;
|
||||
float _SunGlowSize;
|
||||
float _SunGlowStrength;
|
||||
|
||||
half4 _CloudColor;
|
||||
half4 _CloudShadowColor;
|
||||
float _CloudCoverage;
|
||||
float _CloudSoftness;
|
||||
float _CloudScale;
|
||||
float _CloudSpeed;
|
||||
float4 _CloudWindDir;
|
||||
|
||||
float _StarDensity;
|
||||
float _StarTwinkleSpeed;
|
||||
|
||||
half4 _ShootingStarColor;
|
||||
float _ShootingStarRate;
|
||||
|
||||
float _Exposure;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 viewDirOS : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
// La skybox est dessinée autour de la caméra : la position objet du mesh est
|
||||
// directement la direction de vue. On la transmet brute et on la normalise au fragment.
|
||||
Varyings SkyVertex(Attributes IN)
|
||||
{
|
||||
Varyings OUT = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
|
||||
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.viewDirOS = IN.positionOS.xyz;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Compose le ciel dans l'ordre fond -> nuages -> soleil -> étoiles -> filantes.
|
||||
// Toute l'animation lit _SkyTime (synchronisé) et tout dépend de _SunDirection /
|
||||
// _TimeOfDay (synchronisés), donc le rendu est identique sur tous les clients.
|
||||
half4 SkyFragment(Varyings IN) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
||||
|
||||
float3 viewDir = normalize(IN.viewDirOS);
|
||||
|
||||
float3 col = SkyGradient(viewDir,
|
||||
_DayZenith.rgb, _DayHorizon.rgb,
|
||||
_NightZenith.rgb, _NightHorizon.rgb,
|
||||
_TwilightColor.rgb, _HorizonSharpness);
|
||||
|
||||
col += SunGlow(viewDir, _SunGlowColor.rgb, _SunGlowSize, _SunGlowStrength);
|
||||
|
||||
float4 clouds = Clouds(viewDir, _SkyTime * _CloudSpeed,
|
||||
_CloudColor.rgb, _CloudShadowColor.rgb,
|
||||
_CloudCoverage, _CloudSoftness, _CloudScale, _CloudWindDir.xy);
|
||||
col = col * (1.0 - clouds.a) + clouds.rgb;
|
||||
|
||||
col += SunDisk(viewDir, _SunColor.rgb, _SunSize) * (1.0 - clouds.a);
|
||||
|
||||
col += Stars(viewDir, _StarDensity, _StarTwinkleSpeed, _SkyTime) * (1.0 - clouds.a);
|
||||
col += ShootingStars(viewDir, _SkyTime, _ShootingStarColor.rgb, _ShootingStarRate) * (1.0 - clouds.a);
|
||||
|
||||
col *= _Exposure;
|
||||
return half4(col, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80b7948853269e541b4cabcab12ee2ec
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user