POV-Ray : Newsgroups : povray.binaries.images : Confused about a Lightsys IV color : Confused about a Lightsys IV color Server Time
29 Jul 2024 20:15:59 EDT (-0400)
  Confused about a Lightsys IV color  
From: Cousin Ricky
Date: 25 Nov 2013 14:40:03
Message: <web.5293a5a458fdf43f306548240@news.povray.org>
I just tried converting black body spectra to sRGB colors as a sanity check for
a spectral rendering test.  The hues match the output of CIE.inc's Blackbody();
but I don't understand why the 5778 K color is so dark, since the spectral curve
has so much more light than the other two curves, especially in the wavelengths
at which we are most sensitive.  Is there something I did wrong or left out?

Here is the SDL for the image.  It requres module SphereSweep from the Object
Collection (and, of course, Lightsys IV).  The code for the spectrum image
backdrop is omitted, because it references a private include file.
________________________________________________________________________________

#version 3.7;

global_settings { assumed_gamma 1 }

#include "shapes.inc"
#include "spheresweep.inc"
#include "CIE.inc"
//#include "spectrum.inc"
//#include "starcolors.inc"

#declare YTOP = 158;
#declare YBOTTOM = 28;
#declare MIDDLE = 565;
#declare ALIGN = 200 / image_width;
#declare RW = 160/3;

#declare SHORTEST = 380;
#declare LONGEST = 760;
#declare STEP = 5;
#declare N = (LONGEST - SHORTEST) / STEP + 1;

#declare S_FONT = "LiberationSans-Bold.ttf" //substitute your own
#declare S_NARROW = "LiberationSansNarrow-Bold.ttf" //substitute your own
#declare S_LIGHT = "LiberationSans-Regular.ttf" //substitute your own

camera
{ orthographic
  location <MIDDLE - ALIGN, 150, -100>
  right 400 * x
  up 300 * y
}

light_source { -100 * z, rgb 1 parallel point_at 0 }

#default { finish { ambient 0 diffuse 1 } }

//==============================================================================

#declare fn_Index2Wavelength = function (x) { SHORTEST + x * STEP }

#macro Show_spectrum (Kelvins, X)
  #local Max = 0;
  #local Fluxes = array[N]
  #local GraphPts = array[N]
 //Get fluxes by wavelength
  #local I = 0;
  #for (I, 0, N-1)
    #local Fluxes[I] =
      PlanckBlackBody (fn_Index2Wavelength (I) * 1e-9, Kelvins);
    #local Max = max (Max, Fluxes[I]);
  #end
  #for (I, 0, N-1)
    #local Fluxes[I] = Fluxes[I] / Max;
    #local GraphPts[I] =
      <fn_Index2Wavelength (I), YBOTTOM + Fluxes[I] * (YTOP - YBOTTOM), 0>;
  #end
 //Get the color
  #local Flux_map = spline
  { natural_spline
    #for (I, 0, N-1)
      fn_Index2Wavelength (I), Fluxes[I]
    #end
  }
  #local c_Color = rgb Emissive2RGB (Flux_map);
 //Swatch
  union
  { object
    { Round_Box_Union (<-RW, -50, 0>, <RW, 50, 20>, 4)
      pigment { c_Color }
      finish { brilliance 0.75 }
    }
    union
    { Center_Object
      ( text
        { ttf S_FONT concat (str(Kelvins,0,0), " K") 1, 0
          translate 0.5 * y scale 18
        },
        x
      )
      Center_Object
      ( text
        { ttf S_NARROW concat ("<", vstr (3, c_Color, ", ", 0, 3), ">") 1, 0
          translate -0.5 * y scale 12
        },
        x
      )
      Center_Object
      ( text
        { ttf S_FONT concat ("gray = ", str (c_Color.gray, 0, 3)) 1, 0
          translate -1.5 * y scale 12
        },
        x
      )
      pigment { rgb 0 }
      translate -z
    }
    translate <MIDDLE + X - ALIGN, 230, 0>
  }
 //Graph
  #local Radii = array[1] { 2 }
  object
  { SphereSweep_Union (SSWP_NATURAL_SPLINE, GraphPts, Radii, 5)
    pigment { c_Color }
    finish { brilliance 2 }
  }
#end

//Show_spectrum (StarColors_BV2temp (-0.3), -2*RW - 20)
Show_spectrum (30255.637184, -2*RW - 20)
Show_spectrum (5778, 0)
//Show_spectrum (StarColors_BV2temp (1.9), 2*RW + 20)
Show_spectrum (2716.683768, 2*RW + 20)

//================================= BACKDROP ===================================

/* [snip spectrum image code] */

#for (Wl, 400, 750, 50)
  object
  { Center_Object (text { ttf S_LIGHT str(Wl,0,0) 1, 0 }, x)
    scale 10
    translate <Wl, YBOTTOM - 10, 0>
    pigment { rgb 0.5 }
  }
#end


Post a reply to this message


Attachments:
Download 'black_body_graph.png' (44 KB)

Preview of image 'black_body_graph.png'
black_body_graph.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.