Project_WL/Assets/WL/Look/Sky/WLSkyboxPanoramicGround.shader

103 lines
4.7 KiB
Plaintext

// ─────────────────────────────────────────────────────────────────────────────
// WL/Skybox/Panoramic Ground — 위(수평선 위) = 파노라마 하늘 그대로 · 아래(수평선 아래) = 지정한 바닥색 (2026-10-15)
//
// PD 「스카이 박스 추가 후 화면의 색감이 달라진 느낌이야(특히 바다) — 추가 전과 같이 밝아지도록」
// 실측(시간 정지 · 같은 프레임에서 하늘만 교체): 풀·지형 색은 같고(A9C975) **바다만** 바뀌었다(0192DC → 01EDDC).
// 섬 바다 셰이더(Shader Graphs/Water)가 물 너머(_CameraOpaqueTexture)를 섞는데, 바다 밑에는 아무것도 없어 **하늘의 아래 반구**가 비친다.
// 전 하늘(Default-Skybox 절차형)의 아래 반구 = 어두운 회색 → 짙은 파랑 바다 · FS017 의 아래 반구 = 밝은 청록 → 청록 바다.
// ■ 그래서 아래 반구만 전 하늘이 내던 색(_GroundColor · 선형 실측값)으로 칠한다 — 위 반구(보이는 하늘)는 Skybox/Panoramic 과 같은 계산.
// ■ 모바일: 텍스처 1회 + 산술 몇 개(내장 Panoramic 과 같은 급) · 변형 0.
// ─────────────────────────────────────────────────────────────────────────────
Shader "WL/Skybox/Panoramic Ground"
{
Properties
{
_Tint ("Tint Color", Color) = (.5, .5, .5, .5)
[Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _MainTex ("Spherical (HDR)", 2D) = "grey" {}
[HDR] _GroundColor ("Ground Color (below horizon · linear measured)", Color) = (0.37, 0.35, 0.34, 1)
_GroundBlend ("Ground Blend (sin of angle below horizon)", Range(0.001, 0.5)) = 0.05
}
SubShader
{
Tags { "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
Cull Off ZWrite Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
sampler2D _MainTex;
half4 _MainTex_HDR;
half4 _Tint;
half _Exposure;
float _Rotation;
half4 _GroundColor;
float _GroundBlend;
float3 RotateAroundYInDegrees(float3 vertex, float degrees)
{
float alpha = degrees * UNITY_PI / 180.0;
float sina, cosa;
sincos(alpha, sina, cosa);
float2x2 m = float2x2(cosa, -sina, sina, cosa);
return float3(mul(m, vertex.xz), vertex.y).xzy;
}
// 내장 Skybox/Panoramic(위도·경도 360) 과 같은 좌표
inline float2 ToRadialCoords(float3 coords)
{
float3 n = normalize(coords);
float latitude = acos(n.y);
float longitude = atan2(n.z, n.x);
float2 sphereCoords = float2(longitude, latitude) * float2(0.5 / UNITY_PI, 1.0 / UNITY_PI);
return float2(0.5, 1.0) - sphereCoords;
}
struct appdata_t
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 texcoord : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
float3 rotated = RotateAroundYInDegrees(v.vertex.xyz, _Rotation);
o.vertex = UnityObjectToClipPos(rotated);
o.texcoord = v.vertex.xyz;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float3 dir = normalize(i.texcoord);
half4 tex = tex2D(_MainTex, ToRadialCoords(i.texcoord));
half3 c = DecodeHDR(tex, _MainTex_HDR);
c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb * _Exposure;
// 수평선 아래 = 바닥색(바다 너머로 비치는 색) — 수평선에서 _GroundBlend 만큼 내려가며 섞는다
half g = saturate(-dir.y / max(_GroundBlend, 0.001));
c = lerp(c, _GroundColor.rgb, g);
return half4(c, 1);
}
ENDCG
}
}
Fallback Off
}