mipgen: fix dark miplevels in normal maps.
When using GAUSSIAN_NORMALS, image::resampleImage automatically unitizes its output. This means that clients (e.g. mipgen) need to ensure that the source image is in [-1,+1] rather than [0,+1].
This commit is contained in:
@@ -123,12 +123,24 @@ LinearImage vectorsToColors(const LinearImage& image) {
|
||||
LinearImage result(width, height, 3);
|
||||
auto src = (float3 const*) image.getPixelRef();
|
||||
auto dst = (float3*) result.getPixelRef();
|
||||
for (uint32_t n = 0; n < width * height; ++n) {
|
||||
for (uint32_t n = 0, end = width * height; n < end; ++n) {
|
||||
dst[n] = 0.5f * (src[n] + float3(1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LinearImage colorsToVectors(const LinearImage& image) {
|
||||
ASSERT_PRECONDITION(image.getChannels() == 3, "Must be a 3-channel image.");
|
||||
const uint32_t width = image.getWidth(), height = image.getHeight();
|
||||
LinearImage result(width, height, 3);
|
||||
auto src = (float3 const*) image.getPixelRef();
|
||||
auto dst = (float3*) result.getPixelRef();
|
||||
for (uint32_t n = 0, end = width * height; n < end; ++n) {
|
||||
dst[n] = 2.0f * src[n] - float3(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LinearImage extractChannel(const LinearImage& source, uint32_t channel) {
|
||||
const uint32_t width = source.getWidth(), height = source.getHeight();
|
||||
const uint32_t nchan = source.getChannels();
|
||||
|
||||
Reference in New Issue
Block a user