Manta Interactive Ray Tracer Development Mailing List

Text archives Help


Re: [Manta] r1973 - in trunk: Image scenes


Chronological Thread 
  • From: Solomon Boulos <boulos@cs.utah.edu>
  • Cc: MANTA <manta@sci.utah.edu>
  • Subject: Re: [Manta] r1973 - in trunk: Image scenes
  • Date: Mon, 7 Jan 2008 09:54:33 -0800

Now that some sample code exists, I think it's a good time to discuss where tone mapping will be applied. The most common tone mapping operations require floating point values, so it's too late if we've already converted to an 8-bit per channel framebuffer. Some operations require that the full image be available (like Erik Reinhard's tone mapper) so that things like average brightness can be computed.

At some point, there was talk of performing the tone mapping on GPUs whenever available. This would suggest using a floating point format of some sort to ship data to the GPU and then to perform all the tone mapping stages there. Can someone drum up a bloom filter, a reinhard tone mapper, and a simple sRGB tone mapper?

Also, on Tiger systems (which I imagine we still care about?), the only default color space available is GenericRGB. Can someone on a Tiger system tell me if /System/Library/ColorSync/Profiles contains an sRGB Profile.icc? It might just be that in Tiger nobody took the time to make that a default color space like they did in Leopard. If that's the case then on pre-leopard systems, we can create the color space from that file instead.

Solomon

On Jan 7, 2008, at 9:35 AM, boulos@sci.utah.edu wrote:

Author: boulos
Date: Mon Jan  7 10:35:27 2008
New Revision: 1973

Added:
  trunk/scenes/macbeth.cc
Modified:
  trunk/Image/CoreGraphicsFile.cc
  trunk/Image/SimpleImage_special.cc
  trunk/scenes/CMakeLists.txt
Log:
Image/CoreGraphicsFile.cc

Someone left tabs in this file, but more importantly on Leopard we
can tell CoreGraphics to give us SRGB (on earlier systems only
GenericRGB is available and is slightly off).

Image/SimpleImage_special.cc

Leaving a note about how I tried PowSSE, but have found it to be
inadequate for color matching.

scenes/CMakeLists.txt
scenes/macbeth.cc

Adding a macbeth color checker scene. You specify your image texture,
and it renders it. My image is flipped for some reason (mirrored
across Y), but the colors now come out right.


Modified: trunk/Image/CoreGraphicsFile.cc
= = = = = = = = ======================================================================
--- trunk/Image/CoreGraphicsFile.cc     (original)
+++ trunk/Image/CoreGraphicsFile.cc     Mon Jan  7 10:35:27 2008
@@ -16,7 +16,7 @@

namespace /* anonymous */ {

-  CGImageRef loadImage(const std::string& filename)
+  CGImageRef loadImage(const std::string& filename)
  {
CFStringRef path = CFStringCreateWithCString(NULL, filename.c_str(), 0);
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, false);
@@ -31,7 +31,7 @@
    keys[1] = kCGImageSourceShouldAllowFloat;
    values[1] = (CFTypeRef)kCFBooleanTrue;

- options = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, 2,
+ options = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, 2,
                                 &kCFTypeDictionaryKeyCallBacks,
                                 &kCFTypeDictionaryValueCallBacks);

@@ -48,7 +48,7 @@
    return image;
  }

-  CGContextRef createRGBABitmapContext(CGImageRef image, void* data)
+  CGContextRef createRGBABitmapContext(CGImageRef image, void* data)
  {
    CGContextRef context = NULL;
    CGColorSpaceRef color_space;
@@ -61,7 +61,11 @@
    bytes_per_row = (w * 4 * sizeof(float));
    byte_count = bytes_per_row * h;

+#ifdef APPLE_LEOPARD
+    color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+#else
    color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+#endif
    if(color_space == NULL) {
throw InternalError("Could not create CoreGraphics bitmap context");
    }
@@ -72,7 +76,7 @@
                                    bytes_per_row,
                                    color_space,
                                    kCGImageAlphaNoneSkipLast |
-                                    kCGBitmapFloatComponents  |
+                                    kCGBitmapFloatComponents  |
                                    kCGBitmapByteOrder32Host);


@@ -82,7 +86,7 @@
  }
}

-extern "C"
+extern "C"
bool isCoreGraphics( const std::string& filename )
{
  // try to create an image source for the file
@@ -92,16 +96,16 @@
  CFDictionaryRef options = NULL;
  CFStringRef keys[2];
  CFTypeRef values[2];
-
+
  keys[0] = kCGImageSourceShouldCache;
  values[0] = (CFTypeRef)kCFBooleanTrue;
  keys[1] = kCGImageSourceShouldAllowFloat;
  values[1] = (CFTypeRef)kCFBooleanTrue;
-
- options = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, 2,
+
+ options = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, 2,
                               &kCFTypeDictionaryKeyCallBacks,
                               &kCFTypeDictionaryValueCallBacks);
-
+
  image_source = CGImageSourceCreateWithURL(url, options);

  bool readable = (image_source ? true : false);
@@ -111,13 +115,13 @@
  return readable;
}

-extern "C"
+extern "C"
void writeCoreGraphics( const Image* image, const std::string &filename, int which=0 )
{
throw OutputError("CoreGraphics File I/O does not currently support writing");
}

-extern "C"
+extern "C"
Image* readCoreGraphics( const std::string& filename )
{
  CGImageRef cg_image = loadImage(filename);
@@ -161,7 +165,7 @@
}

// Returns true if this reader is supported
-extern "C"
+extern "C"
bool CoreGraphicsSupported()
{
  return true;

Modified: trunk/Image/SimpleImage_special.cc
= = = = = = = = ======================================================================
--- trunk/Image/SimpleImage_special.cc  (original)
+++ trunk/Image/SimpleImage_special.cc  Mon Jan  7 10:35:27 2008
@@ -19,6 +19,8 @@
  // http://www.opengl.org/registry/specs/EXT/framebuffer_sRGB.txt
  __m128 use_gamma = _mm_cmplt_ps(_mm_set1_ps(.0031308f), val);
  __m128 linear_ver = _mm_mul_ps(val, _mm_set1_ps(12.92f));
+  // NOTE(boulos): PowSSE doesn't seem to cut it for this exponent..,
+  // we might want to do a lookup table or a separate SSE pow...
__m128 gamma_ver = _mm_sub_ps(_mm_mul_ps(_mm_set1_ps(1.055f), PowSSEMathH(val, _mm_set1_ps(0.41666f), use_gamma)), _mm_set1_ps(. 055f));
  return mask4(use_gamma, gamma_ver, linear_ver);
#else

Modified: trunk/scenes/CMakeLists.txt
= = = = = = = = ======================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Mon Jan  7 10:35:27 2008
@@ -115,3 +115,10 @@
   ADD_LIBRARY(scene_area_light area_light.cc)
   TARGET_LINK_LIBRARIES(scene_area_light ${MANTA_SCENE_LINK})
ENDIF(SCENE_AREA_LIGHT)
+
+# macbeth color checker scene
+SET(SCENE_MACBETH TRUE CACHE BOOL "Macbeth test")
+IF(SCENE_MACBETH)
+   ADD_LIBRARY(scene_macbeth macbeth.cc)
+   TARGET_LINK_LIBRARIES(scene_macbeth ${MANTA_SCENE_LINK})
+ENDIF(SCENE_MACBETH)

Added: trunk/scenes/macbeth.cc
= = = = = = = = ======================================================================
--- (empty file)
+++ trunk/scenes/macbeth.cc     Mon Jan  7 10:35:27 2008
@@ -0,0 +1,75 @@
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Exceptions/IllegalValue.h>
+#include <Core/Exceptions/InputError.h>
+#include <Core/Util/Args.h>
+#include <Core/Util/Preprocessor.h>
+#include <Interface/LightSet.h>
+#include <Interface/Scene.h>
+#include <Model/AmbientLights/ConstantAmbient.h>
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Groups/Group.h>
+#include <Model/Lights/DirectionalLight.h>
+#include <Model/Materials/CopyTextureMaterial.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/TexCoordMappers/LinearMapper.h>
+#include <Model/Textures/ImageTexture.h>
+
+#include <iostream>
+
+using namespace Manta;
+
+void addLights( LightSet* lights)
+{
+  lights->add(new DirectionalLight(Vector(0, 0, 1), Color::white()));
+}
+
+MANTA_PLUGINEXPORT
+Scene* make_scene(const ReadContext&, const vector<string>& args)
+{
+  std::string filename;
+  for(size_t i = 0; i < args.size(); ++i) {
+    std::string arg = args[i];
+    if(arg == "-file") {
+      if(!getStringArg(i, args, filename))
+        throw IllegalArgument("scene macbeth -file", i , args);
+    } else {
+      std::cerr << "Unknown option: " << arg << "\n";
+    }
+  }
+
+  if (filename == "") {
+    throw InputError("Filename required for macbeth scene");
+  }
+
+  Vector up( 0.0f, 1.0f, 0.0f );
+  Vector right( 1.0f, 0.0f, 0.0f );
+
+  // Start adding geometry
+  Group* group = new Group();
+  Scene* scene = new Scene();
+
+ scene->setBackground( new ConstantBackground( Color(RGB(.5, .5, . 5) ) ) );
+
+ ImageTexture<Color>* texture = LoadColorImageTexture(filename, &std::cerr, true);
+  Material* image = new CopyTextureMaterial(texture);
+ Primitive* board = new Parallelogram(image, Vector(0, 0, 0), Vector(6, 0, 0), Vector(0, 4, 0));
+ board->setTexCoordMapper( new LinearMapper( Vector(0, 0, 0), Vector(6,0,0), Vector(0, 4, 0), Vector(0,0,1)) );
+
+  group->add(board);
+  scene->setObject(group);
+
+  LightSet* lights = new LightSet();
+  addLights( lights );
+
+  lights->setAmbientLight(new ConstantAmbient( Color::black()));
+  scene->setLights(lights);
+
+  // Add a default camera
+  Vector eye(3,2,-10);
+  Vector lookat(3,2,0);
+  Real   fov=45;
+  scene->addBookmark("default view", eye, lookat, up, fov, fov);
+
+  return scene;
+}
+






Archive powered by MHonArc 2.6.16.

Top of page