MCPcopy Create free account
hub / github.com/LuxCoreRender/LuxCore / GetSpectrumValue

Method GetSpectrumValue

src/slg/textures/densitygrid.cpp:211–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211Spectrum DensityGridTexture::GetSpectrumValue(const HitPoint &hitPoint) const {
212 const Point P(mapping->Map(hitPoint));
213
214 float x, y, z;
215 int vx, vy, vz;
216
217 switch (imageMap->GetStorage()->wrapType) {
218 case ImageMapStorage::REPEAT:
219 x = P.x * nx;
220 vx = Floor2Int(x);
221 x -= vx;
222 vx = Mod(vx, nx);
223 y = P.y * ny;
224 vy = Floor2Int(y);
225 y -= vy;
226 vy = Mod(vy, ny);
227 z = P.z * nz;
228 vz = Floor2Int(z);
229 z -= vz;
230 vz = Mod(vz, nz);
231 break;
232 case ImageMapStorage::BLACK:
233 if (P.x < 0.f || P.x >= 1.f ||
234 P.y < 0.f || P.y >= 1.f ||
235 P.z < 0.f || P.z >= 1.f)
236 return 0.f;
237 x = P.x * nx;
238 vx = Floor2Int(x);
239 x -= vx;
240 y = P.y * ny;
241 vy = Floor2Int(y);
242 y -= vy;
243 z = P.z * nz;
244 vz = Floor2Int(z);
245 z -= vz;
246 break;
247 case ImageMapStorage::WHITE:
248 if (P.x < 0.f || P.x >= 1.f ||
249 P.y < 0.f || P.y >= 1.f ||
250 P.z < 0.f || P.z >= 1.f)
251 return 1.f;
252 x = P.x * nx;
253 vx = Floor2Int(x);
254 x -= vx;
255 y = P.y * ny;
256 vy = Floor2Int(y);
257 y -= vy;
258 z = P.z * nz;
259 vz = Floor2Int(z);
260 z -= vz;
261 break;
262 case ImageMapStorage::CLAMP:
263 x = Clamp(P.x, 0.f, 1.f) * nx;
264 vx = Min(Floor2Int(x), nx - 1);
265 x -= vx;
266 y = Clamp(P.y, 0.f, 1.f) * ny;
267 vy = Min(Floor2Int(P.y * ny), ny - 1);
268 y -= vy;

Callers

nothing calls this directly

Calls 7

Floor2IntFunction · 0.85
MinFunction · 0.85
LerpFunction · 0.85
GetStorageMethod · 0.80
ModFunction · 0.50
ClampFunction · 0.50
MapMethod · 0.45

Tested by

no test coverage detected