MCPcopy Create free account
hub / github.com/NVIDIA-RTX/STBN / WriteOutUVAndDirsFile

Function WriteOutUVAndDirsFile

Libraries/Vector/Debug/DebugFileExport.cpp:44–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void WriteOutUVAndDirsFile(const ImportanceSamplingData& isData, const std::string baseOutputFileName, const Dimensions3D& dims)
45{
46 std::vector<unsigned char> output_uv(isData.isw * isData.ish * 4, 0);
47 std::vector<unsigned char> output_dir(isData.isw * isData.ish * 4, 0);
48 for (size_t index = 0; index < isData.isw * isData.ish; ++index)
49 {
50 int ix = int(index % isData.isw);
51 int iy = int(index / isData.isw);
52
53 float uvx = (float(ix) + 0.5f) / float(isData.isw);
54 float uvy = (float(iy) + 0.5f) / float(isData.ish);
55
56 output_uv[index * 4 + 0] = (unsigned char)Clamp(uvx * 256.0f, 0.0f, 255.0f);
57 output_uv[index * 4 + 1] = (unsigned char)Clamp(uvy * 256.0f, 0.0f, 255.0f);
58 output_uv[index * 4 + 2] = 0;
59 output_uv[index * 4 + 3] = 255;
60
61 // TODO
62 Float3 dir = SphericalMapUVToDirection(Float2{ uvx, uvy });
63 output_dir[index * 4 + 0] = (unsigned char)Clamp(dir[0] * 256.0f, 0.0f, 255.0f);
64 output_dir[index * 4 + 1] = (unsigned char)Clamp(dir[1] * 256.0f, 0.0f, 255.0f);
65 output_dir[index * 4 + 2] = (unsigned char)Clamp(dir[2] * 256.0f, 0.0f, 255.0f);
66 output_dir[index * 4 + 3] = 255;
67 }
68
69 std::stringstream uvSS;
70 uvSS << baseOutputFileName << "_debuguv_" << dims.x << "x" << dims.y << "x" << dims.z << ".png";
71 stbi_write_png(uvSS.str().c_str(), isData.isw, isData.ish, 4, output_uv.data(), 0);
72
73 std::stringstream dirSS;
74 dirSS << baseOutputFileName << "_debugdir_" << dims.x << "x" << dims.y << "x" << dims.z << ".png";
75 stbi_write_png(dirSS.str().c_str(), isData.isw, isData.ish, 4, output_dir.data(), 0);
76}
77
78void WriteOutEnergyRecord(const std::vector<float>& energyRecord, const std::string& baseFileName, const Dimensions3D& dims)
79{

Callers

nothing calls this directly

Calls 2

ClampFunction · 0.85

Tested by

no test coverage detected