POV-Ray : Newsgroups : povray.general : strange problem with srgb color in light_source : strange problem with srgb color in light_source Server Time
9 May 2021 07:38:00 EDT (-0400)
  strange problem with srgb color in light_source  
From: Kenneth
Date: 31 Mar 2021 12:10:00
Message: <web.60649d9bb9b7dccdd98418916e066e29@news.povray.org>
[running Windows 10]

While updating a very old scene's rgb colors to srgb, I came across what seems
to be a bug when using a *multiplied* srgb color in a light_source--
specifically, when using fade_distance and fade_power in the light. The effect
is as if fade_distance/fade power are not working at all-- the light is
completely blasted-out and too bright-- whereas those features do work correctly
with rgb colors. I get the same results in v3.7.0 and in the latest experimental
v3.8xx Windows build that 'piggybacks' on v3.7.

I originally thought that this was a consequence of merely multiplying an srgb
color-- due to the underlying complex math formula for converting rgb-to-srgb.
But that's not the reason, because I experimented and found a rather strange way
to solve the problem-- although *why* the fix works is kind of a mystery too.

I've included a simple test scene to see the results, which has three choices
for which 'kind' of color to use.

When simply specifying srgb <.5,.3,.7>*50000  *within* the light's code, the
effect is super-bright, as if fade_distance and fade_power are non-existent. But
when pre-#declaring the color as  srgb <.5,.3,.7>,  the color and lighting
intensity both work as expected. For some reason, the  srgb  keyword itself
seems to be part of the problem, when used *directly* in the light_source block.

It would be interesting to know if others who use Linux builds of the source
code see the same problem, and if the solution works there too.

-------
#version 3.7;
global_settings{assumed_gamma 1.0}
#default{finish{ambient .07 emission 0 diffuse .85}}

camera {
  perspective
  location  <0, 4, -4>
  look_at   <0, 0,  0>
  right     x*image_width/image_height
  angle 67
}

#declare TEMP_COLOR = srgb <.5,.3,.7>; // pre-#declaring the srgb color
// solves the multiplication problem in the light

light_source {
  0*x
// three choices...

//color rgb <.5,.3,.7>*50000 // this works OK

  // OR...
color srgb <.5,.3,.7>*50000    // this does NOT work correctly-- very
// odd results

  // OR...
 //color TEMP_COLOR*50000 // this DOES work correctly

  looks_like{sphere{0,.1
  texture{pigment{srgb <1,.5,.5>}finish{ambient 0 emission 1 diffuse 0}}}}
  fade_distance .01
  fade_power 2.0
  translate 2*y
}

plane{y,0 pigment{srgb .5}}

// objects
#declare SC = seed(34);
#for(i,1,15)
cylinder{0, 1*y,.2
pigment{srgb <.3 + .7*rand(SC),.3 + .7*rand(SC),.3 + .7*rand(SC)>}
translate 2*x
rotate i*360/15*y
}
#end


Post a reply to this message

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