-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlpsh.bt
138 lines (109 loc) · 3.71 KB
/
lpsh.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "common/common.bt"
#include "common/gr_sh_common.bt"
typedef struct
{
half r;
half g;
half b;
half skyVisibility;
} ShCoefficients <read = Str("(%s, %s, %s, %s)", ReadHalf(r), ReadHalf(g), ReadHalf(b), ReadHalf(skyVisibility))>;
typedef struct(int selfIndex)
{
local int SelfIndex = selfIndex;
// Band Basis
ShCoefficients c00; // 0 0
ShCoefficients c10; // 1 -1
ShCoefficients c11; // 1 0
ShCoefficients c12; // 1 1
ShCoefficients c20; // 2 -2
ShCoefficients c21; // 2 -1
ShCoefficients c22; // 2 0
ShCoefficients c23; // 2 1
ShCoefficients c24; // 2 2
// a0 = sqrt(1/(4pi)) = 0.282095
// a1 = sqrt(3/(4pi)) = 0.488603
// a2 = sqrt(15/(4pi)) = 1.092548
// a3 = sqrt(5/(16pi)) = 0.315392
// a4 = sqrt(15/(16pi)) = 0.546274
// Stored in SH matrix used in SH_SphereMap.hlsl:
// [ +a4*c24 , a2*c20/2 , a2*c23/2 , a1*c12/2 ]
// [ a2*c20/2 , -a4*c24 , a2*c21/2 , a1*c10/2 ]
// [ a2*c23/2 , a2*c21/2 , 3*a3*c22 , a1*c11/2 ]
// [ a1*c12/2 , a1*c10/2 , a1*c11/2 , a0*c00-a3*c22 ]
} CoefficientSet <read = ReadCoefficientSetString(SelfIndex < 0 ? 0 : parentof(parentof(this)).Times[SelfIndex], SelfIndex), bgcolor = 0x00ff00, optimize = true>;
string ReadCoefficientSetString(uint time, int index)
{
return index < 0 ? "" : ReadUInt24HTime(time);
}
typedef struct
{
Assert(parentof(this).Flags == 1); Assert(parentof(this).ParentNodeOffset == 0); Assert(parentof(this).ChildNodeOffset == 0);
local uint numDiv = parentof(this).Parameter[GetFoxDataNodeParamIndex(parentof(this), "numDiv")].Value;
local uint numLightProbes = parentof(this).Parameter[GetFoxDataNodeParamIndex(parentof(this), "numLightProbes")].Value;
// Only in Version 4 files
//local uint formatType = parentof(this).Parameter[GetFoxDataNodeParamIndex(parentof(this), "formatType")].Value; Assert(formatType == 1);
uint Times[numDiv] <hidden = true, optimize = true>;
FAlign(16);
struct
{
int NameStringOffset <hidden = true>;
int DataOffset <hidden = true>;
uint enable24hSH : 1 <hidden = true>;
uint enableWeatherSH : 1 <hidden = true>;
uint enableRelatedLightSH : 1 <hidden = true>;
uint enableOcclusionMode : 1 <hidden = true>; Assert(enableOcclusionMode == 0);
uint Padding : 28 <hidden = true>; Assert(Padding == 0);
local uint NextStartPos = FTell();
FSeek(DataOffset);
local int k;
if (enable24hSH)
{
for (k = 0; k < numDiv; k++)
CoefficientSet Weather0(k);
}
else
{
CoefficientSet Weather0(-1);
}
if (enableWeatherSH)
{
if (enable24hSH)
{
for (k = 0; k < numDiv; k++)
CoefficientSet Weather1(k);
}
else
{
CoefficientSet Weather1(-1);
}
}
if (enableRelatedLightSH)
{
CoefficientSet RelatedLight(-1)[2];
}
if (enableOcclusionMode)
{
CoefficientSet Occlusion(-1)[1];
}
FSeek(NextStartPos);
} Probes[numLightProbes] <read = ReadProbeMetadata(NameStringOffset, enable24hSH, enableWeatherSH, enableRelatedLightSH, enableOcclusionMode), bgcolor = 0xff00ff, optimize = false>;
} LightProbeSHCoefficients <bgcolor = 0x00aaff>;
string ReadProbeMetadata(uint nameStringOffset, uint enable24hSH, uint enableWeatherSH, uint enableRelatedLightSH, uint enableOcclusionMode)
{
string result = ReadString(nameStringOffset);
if (enable24hSH)
result += ", enable24hSH";
if (enableWeatherSH)
result += ", enableWeatherSH";
if (enableRelatedLightSH)
result += ", enableRelatedLightSH";
if (enableOcclusionMode)
result += ", enableOcclusionMode";
return result;
}
#define FOX_DATA_PAYLOAD LightProbeSHCoefficients
#include "common/FoxData_common.bt"
FoxDataHeader Header;
Assert(Header.Version == 3 || Header.Version == 4);
FSeek(Header.NodesOffset);
FoxDataNodes Nodes;