-
Notifications
You must be signed in to change notification settings - Fork 0
/
planet_overlay_macros.inl
134 lines (114 loc) · 4.55 KB
/
planet_overlay_macros.inl
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
void TW_CALL antSetWaveLength(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const glm::vec3 waveLength = *(glm::vec3*)value;
planet->m_atmosphereConstants->m_waveLength = waveLength;
planet->m_uniforms.v3_invWavelength = glm::vec3(powf(waveLength.x, -4.0), powf(waveLength.y, -4.0), powf(waveLength.z, -4.0));
}
void TW_CALL antSetInnerRadius(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float innerRadius = *(float*)value;
planet->m_atmosphereConstants->m_innerRadius = innerRadius;
planet->m_uniforms.f_innerRadius = innerRadius;
planet->m_uniforms.f_innerRadius2 = innerRadius * innerRadius;
planet->m_uniforms.f_scale = 1.0f / (planet->m_atmosphereConstants->m_outerRadius - innerRadius);
planet->m_uniforms.f_scaleOverScaleDepth = planet->m_uniforms.f_scale / planet->m_atmosphereConstants->m_scaleDepth;
}
void TW_CALL antSetOuterRadius(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float outerRadius = *(float*)value;
planet->m_atmosphereConstants->m_outerRadius = outerRadius;
planet->m_uniforms.f_outerRadius = outerRadius;
planet->m_uniforms.f_outerRadius2 = outerRadius * outerRadius;
planet->m_uniforms.f_scale = 1.0f / (outerRadius - planet->m_atmosphereConstants->m_innerRadius);
planet->m_uniforms.f_scaleOverScaleDepth = planet->m_uniforms.f_scale / planet->m_atmosphereConstants->m_scaleDepth;
}
void TW_CALL antSetKr(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float kr = *(float*)value;
planet->m_atmosphereConstants->m_kr = kr;
planet->m_uniforms.f_krESun = kr * planet->m_atmosphereConstants->m_eSun;
planet->m_uniforms.f_kr4PI = kr * 4.0f * PI;
}
void TW_CALL antSetKm(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float km = *(float*)value;
planet->m_atmosphereConstants->m_km = km;
planet->m_uniforms.f_kmESun = km * planet->m_atmosphereConstants->m_eSun;
planet->m_uniforms.f_km4PI = km * 4.0f * PI;
}
void TW_CALL antSetESun(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float eSun = *(float*)value;
planet->m_atmosphereConstants->m_eSun = eSun;
planet->m_uniforms.f_krESun = planet->m_atmosphereConstants->m_kr * eSun;
planet->m_uniforms.f_kmESun = planet->m_atmosphereConstants->m_km * eSun;
}
void TW_CALL antSetG(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float f_g = *(float*)value;
planet->m_atmosphereConstants->m_g = f_g;
planet->m_uniforms.f_g = f_g;
planet->m_uniforms.f_g2 = f_g * f_g;
}
void TW_CALL antSetScaleDepth(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const float scaleDepth = *(float*)value;
planet->m_atmosphereConstants->m_scaleDepth = scaleDepth;
const float scale = 1.0f / (
planet->m_atmosphereConstants->m_outerRadius -
planet->m_atmosphereConstants->m_innerRadius
);
planet->m_uniforms.f_scaleDepth = scaleDepth;
planet->m_uniforms.f_scaleOverScaleDepth = scale / scaleDepth;
}
void TW_CALL antSetSamples(const void* value, void* clientData)
{
Planet* const planet = (Planet*)clientData;
const int samples = *(int*)value;
planet->m_atmosphereConstants->m_samples = samples;
planet->m_uniforms.i_samples = samples;
}
void TW_CALL antGetWaveLength(void* value, void* clientData)
{
*(glm::vec3*)value = ((Planet*)clientData)->m_atmosphereConstants->m_waveLength;
}
void TW_CALL antGetInnerRadius(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_innerRadius;
}
void TW_CALL antGetOuterRadius(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_outerRadius;
}
void TW_CALL antGetKr(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_kr;
}
void TW_CALL antGetKm(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_km;
}
void TW_CALL antGetESun(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_eSun;
}
void TW_CALL antGetG(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_g;
}
void TW_CALL antGetScaleDepth(void* value, void* clientData)
{
*(float*)value = ((Planet*)clientData)->m_atmosphereConstants->m_scaleDepth;
}
void TW_CALL antGetSamples(void* value, void* clientData)
{
*(int*)value = ((Planet*)clientData)->m_atmosphereConstants->m_samples;
}