Skip to content

Commit

Permalink
Merge branch 'release-1.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffamstutz committed Dec 1, 2016
2 parents 06e2b67 + e2a5e3a commit 95ccc33
Show file tree
Hide file tree
Showing 23 changed files with 6,906 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Version History
---------------

### Changes in v1.1.2:

- Various bugfixes related to normalization, epsilons and debug
messages

### Changes in v1.1.1:

- Fixed support of first generation Intel® Xeon Phi™ coprocessor
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OSPRay
======

This is release v1.1.1 of OSPRay. For changes and new features see the
This is release v1.1.2 of OSPRay. For changes and new features see the
[changelog](CHANGELOG.md). Also visit http://www.ospray.org for more
information.

Expand Down
3 changes: 0 additions & 3 deletions apps/common/miniSG/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ IF (APPLE)
# but then it no longer works with the mac-version of Qt, so we currently
# pick qt compatiblity over magick compatibility.
SET(USE_IMAGE_MAGICK OFF)
ELSE()
OPTION(USE_IMAGE_MAGICK "Use ImageMagick for ModelViewer's Texture loaders.")
MARK_AS_ADVANCED(USE_IMAGE_MAGICK)
ENDIF()

IF (USE_IMAGE_MAGICK)
Expand Down
53 changes: 53 additions & 0 deletions apps/common/miniSG/miniSG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
// ======================================================================== //

#include "miniSG.h"
#include "stb_image.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#ifdef USE_IMAGEMAGICK
//#define MAGICKCORE_QUANTUM_DEPTH 16
//#define MAGICKCORE_HDRI_ENABLE 1
Expand Down Expand Up @@ -246,6 +249,56 @@ namespace ospray {
}
}
}
#else
int width,height,n;
const bool hdr = stbi_is_hdr(fileName.str().c_str());
unsigned char* pixels = nullptr;
if (hdr)
pixels = (unsigned char*)stbi_loadf(fileName.str().c_str(), &width, &height, &n, 0);
else
pixels = stbi_load(fileName.str().c_str(),&width,&height,&n,0);
if (n < 3) //TODO: it seems that grayscale bump maps with > 8 bit crash
{
std::cout << "WARNING: ignoring texture with < 3 channels. Turn on USE_IMAGEMAGICK to fully utilize this scenes textures\n";
return tex;
}
tex = new Texture2D;
tex->width = width;
tex->height = height;
tex->channels = n;
tex->depth = hdr ? 4 : 1;
tex->prefereLinear = prefereLinear;
unsigned char MaxRGB = 1;
float rcpMaxRGB = 1.0f/float(MaxRGB);
if (!pixels) {
std::cerr << "#osp:minisg: failed to load texture '"+fileName.str()+"'" << std::endl;
delete tex;
tex = nullptr;
} else {
tex->data = new unsigned char[tex->width*tex->height*tex->channels*tex->depth];
// convert pixels and flip image (because OSPRay's textures have the origin at the lower left corner)
for (size_t y=0; y<tex->height; y++) {
for (size_t x=0; x<tex->width; x++) {
const unsigned char *pixel = &pixels[(y*tex->width+x)*tex->channels];
if (hdr) {
printf("loading hdr image\n");
float *dst = &((float*)tex->data)[(x+(tex->height-1-y)*tex->width)*tex->channels];
*dst++ = pixel[0] * rcpMaxRGB;
*dst++ = pixel[1] * rcpMaxRGB;
*dst++ = pixel[2] * rcpMaxRGB;
if (tex->channels == 4)
*dst++ = pixel[3] * rcpMaxRGB;
} else {
unsigned char *dst = &((unsigned char*)tex->data)[((tex->height-1-y)*tex->width+x)*tex->channels];
*dst++ = pixel[0];
*dst++ = pixel[1];
*dst++ = pixel[2];
if (tex->channels == 4)
*dst++ = pixel[3];
}
}
}
}
#endif
}
textureCache[fileName.str()] = tex;
Expand Down
Loading

0 comments on commit 95ccc33

Please sign in to comment.