Skip to content
This repository was archived by the owner on Dec 24, 2023. It is now read-only.

Commit 5c1ff0c

Browse files
committed
rad: Ignore texlights during neighbour sampling
1 parent 6e7b84f commit 5c1ff0c

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/rad/src/lightmap_writer.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,31 @@ void rad::LightmapWriter::sampleLightmap(FaceLightmap &lm, size_t faceIdx, float
109109
for (unsigned neighbourIdx : neighbours) {
110110
Face &neighbour = m_RadSim.m_Faces[neighbourIdx];
111111

112-
if (neighbourIdx != faceIdx && neighbour.hasLightmap() &&
113-
normalDir == !!neighbour.nPlaneSide) {
114-
glm::vec3 neighbourSamples[4] = {};
115-
glm::vec2 luxelPosHere = neighbour.worldToFace(luxelWorldPos);
116-
sampleFace(neighbour, luxelPosHere, radius, glm::vec2(filterk),
117-
neighbourSamples, weightSum, true);
118-
119-
// Adjust lightstyles
120-
for (int i = 0; i < 4; i++) {
121-
int idx = neighbour.findLightstyle(face.nStyles[i]);
122-
123-
if (idx != -1) {
124-
output[i] += neighbourSamples[idx];
125-
}
112+
if (neighbourIdx == faceIdx || !neighbour.hasLightmap()) {
113+
continue;
114+
}
115+
116+
if (normalDir != !!neighbour.nPlaneSide) {
117+
// Wrong side
118+
continue;
119+
}
120+
121+
if (!isNullVector(neighbour.vLightColor)) {
122+
// Ignore texlights, they have insane color values
123+
continue;
124+
}
125+
126+
glm::vec3 neighbourSamples[4] = {};
127+
glm::vec2 luxelPosHere = neighbour.worldToFace(luxelWorldPos);
128+
sampleFace(neighbour, luxelPosHere, radius, glm::vec2(filterk),
129+
neighbourSamples, weightSum, true);
130+
131+
// Adjust lightstyles
132+
for (int i = 0; i < 4; i++) {
133+
int idx = neighbour.findLightstyle(face.nStyles[i]);
134+
135+
if (idx != -1) {
136+
output[i] += neighbourSamples[idx];
126137
}
127138
}
128139
}

0 commit comments

Comments
 (0)