Skip to content

Commit c7544c9

Browse files
author
lilxyzw
committed
fix: get light direction from Adaptive Probe Volumes #362
1 parent 474de3c commit c7544c9

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

Assets/lilToon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.3.1] - 2025-10-09
8+
### Fixed
9+
- Get light direction from Adaptive Probe Volumes
10+
711
## [2.3.0] - 2025-10-06
812
### Added
913
- Adaptive Probe Volumes

Assets/lilToon/CHANGELOG_JP.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.3.1] - 2025-10-09
8+
### 修正
9+
- Adaptive Probe Volumesからライト方向を取得するように
10+
711
## [2.3.0] - 2025-10-06
812
### 追加
913
- Adaptive Probe Volumes対応
1014

11-
### Fixed
15+
### 修正
1216
- AudioLinkMaskが頂点シェーダーで動作しない
1317
- カスタムシェーダーのInspectorでエラー
1418
- 逆光ライトの透明度が反映されていない

Assets/lilToon/Shader/Includes/lil_common_functions.hlsl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,31 @@ void lilGetToonSHDoubleAPV(float3 lightDirection, float3 positionWS, float3 norm
10801080
#endif
10811081
}
10821082

1083+
float3 lilGetFixedLightDirectionAPV(float3 positionWS, float3 normalWS, float4 lightDirectionOverride)
1084+
{
1085+
float3 mainDir = LIL_MAINLIGHT_DIRECTION * lilLuminance(LIL_MAINLIGHT_COLOR);
1086+
float4 SHAr = unity_SHAr;
1087+
float4 SHAg = unity_SHAg;
1088+
float4 SHAb = unity_SHAb;
1089+
float3 V = normalize(lilViewDirection(positionWS));
1090+
APVSample apvSample = SampleAPV(positionWS, normalWS, lilGetRenderingLayer(), V);
1091+
if (apvSample.status != APV_SAMPLE_STATUS_INVALID)
1092+
{
1093+
apvSample.Decode();
1094+
SHAr = half4(apvSample.L1_R, apvSample.L0.r);
1095+
SHAg = half4(apvSample.L1_G, apvSample.L0.g);
1096+
SHAb = half4(apvSample.L1_B, apvSample.L0.b);
1097+
}
1098+
1099+
float3 sh9Dir = SHAr.xyz * 0.333333 + SHAg.xyz * 0.333333 + SHAb.xyz * 0.333333;
1100+
float3 L = float3(sh9Dir.x, abs(sh9Dir.y), sh9Dir.z) + mainDir + lilGetCustomLightDirection(lightDirectionOverride);
1101+
return L;
1102+
}
1103+
10831104
void lilGetLightColorDoubleAPV(float3 positionWS, float3 normalWS, out float3 lightColor, out float3 indLightColor)
10841105
{
10851106
float3 shMax, shMin;
1086-
lilGetToonSHDoubleAPV(lilGetLightDirectionForSH9(), positionWS, normalWS, shMax, shMin);
1107+
lilGetToonSHDoubleAPV(lilGetFixedLightDirectionAPV(positionWS, normalWS, float4(0,0.001,0,0)), positionWS, normalWS, shMax, shMin);
10871108
lightColor = LIL_MAINLIGHT_COLOR + shMax;
10881109
indLightColor = saturate(shMin);
10891110
}

Assets/lilToon/Shader/Includes/lil_common_macro.hlsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,13 @@ struct lilLightData
21242124
LIL_APPLY_LTCGI(o) \
21252125
LIL_APPLY_ADDITIONALLIGHT_TO_MAIN(i,o); \
21262126
LIL_CORRECT_LIGHTCOLOR_VS(o.lightColor)
2127+
#elif defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
2128+
#define LIL_CALC_MAINLIGHT(i,o) \
2129+
lilLightData o; \
2130+
o.lightDirection = lilGetFixedLightDirectionAPV(i.positionWS, 0, _LightDirectionOverride); \
2131+
LIL_CALC_TWOLIGHT(i,o); \
2132+
LIL_APPLY_ADDITIONALLIGHT_TO_MAIN(i,o); \
2133+
LIL_CORRECT_LIGHTCOLOR_VS(o.lightColor)
21272134
#else
21282135
#define LIL_CALC_MAINLIGHT(i,o) \
21292136
lilLightData o; \

Assets/lilToon/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jp.lilxyzw.liltoon",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"displayName": "lilToon",
55
"description": "Feature-rich toon shader.",
66
"unity": "2022.3",
@@ -9,7 +9,7 @@
99
"licensesUrl": "https://github.com/lilxyzw/lilToon/blob/master/Assets/lilToon/LICENSE",
1010
"license": "MIT",
1111
"keywords": ["Toon", "Shader", "Material"],
12-
"url" : "https://github.com/lilxyzw/lilToon/releases/download/2.3.0/jp.lilxyzw.liltoon-2.3.0.zip?",
12+
"url" : "https://github.com/lilxyzw/lilToon/releases/download/2.3.1/jp.lilxyzw.liltoon-2.3.1.zip?",
1313
"repo" : "https://lilxyzw.github.io/vpm-repos/vpm.json",
1414
"legacyFolders" : {
1515
"Assets\\lilToon" : "05d1d116436047941ad97d1b9064ee05"

0 commit comments

Comments
 (0)