Skip to content

Commit

Permalink
Traktor: Fixed some glitches in IBL probe generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Nov 2, 2023
1 parent be716d2 commit 6fdfcd7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions code/Drawing/CubeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ void CubeMap::set(const Vector4& direction, const Color4f& value)
m_side[side]->setPixel(x, y, value);
}

void CubeMap::set(int32_t side, int32_t x, int32_t y, const Color4f& value)
{
m_side[side]->setPixel(x, y, value);
}

Color4f CubeMap::get(const Vector4& direction) const
{
const Vector4 dir = direction.normalized();
Expand Down
3 changes: 3 additions & 0 deletions code/Drawing/CubeMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class T_DLLCLASS CubeMap : public Object
/*! Set pixel value at direction. */
void set(const Vector4& direction, const Color4f& value);

/*! */
void set(int32_t side, int32_t x, int32_t y, const Color4f& value);

/*! Get pixel value from direction. */
Color4f get(const Vector4& direction) const;

Expand Down
6 changes: 3 additions & 3 deletions code/Shape/Editor/Bake/BakePipelineOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void addSky(
const uint32_t textureAssetHash = pipelineBuilder->calculateInclusiveHash(skyComponentData);

Ref< IblProbe > probe = pipelineBuilder->getDataAccessCache()->read< IblProbe >(
Key(0x00000001, 0x00000000, 0x00000000, textureAssetHash),
Key(0x00000003, 0x00000000, 0x00000000, textureAssetHash),
[&]() -> Ref< IblProbe > {
// Read sky image from texture asset.
Path filePath = FileSystem::getInstance().getAbsolutePath(Path(assetPath) + textureAsset->getFileName());
Expand Down Expand Up @@ -287,7 +287,7 @@ void addSky(
{
const Vector2 uv = Quasirandom::hammersley(i, 5000, random);
Vector4 direction = Quasirandom::uniformHemiSphere(uv, d);
direction = lerp(d, direction, 0.125_simd).normalized();
//direction = lerp(d, direction, 0.125_simd).normalized();
Scalar weight = dot3(d, direction);

// Reduce sun influence.
Expand All @@ -302,7 +302,7 @@ void addSky(
}
cl /= totalWeight;
cl = max(cl, Color4f(0.0f, 0.0f, 0.0f, 0.0f));
radianceCube->set(d, cl);
radianceCube->set(side, x, y, cl);
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion code/Shape/Editor/Bake/IblProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Color4f IblProbe::sampleRadiance(const Vector4& direction) const
const int32_t v = (int32_t)(y * (h - 1));

Color4f cl;
m_radiance->getPixel(u, v, cl);
const bool result = m_radiance->getPixel(u, v, cl);
T_FATAL_ASSERT(result);

return cl;
}

Expand Down

0 comments on commit 6fdfcd7

Please sign in to comment.