povray icon indicating copy to clipboard operation
povray copied to clipboard

Port of FS289 - area_illumination with light fading and scattering media

Open wfpokorny opened this issue 8 years ago • 0 comments

http://bugs.povray.org/task/289 as posted by Paul (OJD).

(Changes tangled in media updates... Black box results as of commit 71c1415 on Fri Jan 27 18:04:52 2017 +0100 looks to me:

  1. as if area_illumination is changing scattering media result 37->RC7 until 372 commit above. Not sure about / don't understand Simon's comment to the contrary?

  2. Fade results with area lights still not similar to multiple lights but expected I think.

  3. Fade not accounted for in scattering media.

)

See zip file: FS289.zip


Details:

With reference to http://bugs.povray.org/task/46 (area_illuminate in area lights is not taking fade_distance into account. Closed by Christoph Lipka (clipka) ) Friday, 22 June 2012, 04:12 GMT+5 Reason for closing: Fixed)

still some issue with area illumination and light fading when interacting with media

seems light fade is not taken into account with scattering media. emission and absorption media seem to work fine. occurs with all scattering types.

#version 3.7;

global_settings {
 ambient_light 0
 assumed_gamma 1
}

camera {
  location <0, 3, -5>
  look_at <0, 2, 0>
}


#declare Light = 3; // light 1 = individual lights
                   // light 2 = standard area light
                   // light 3 = area light with area illumination

#declare Fade = 1; // light fading: 1 on, 0 off

#declare Media = 1; // media 1 = scattering
                    // media 2 = emission
                    // media 3 = absorption

#declare Type = 1; // scattering media type

#switch(Light)
 #case(1)

  #declare Ls = light_source {
    0
    1/7
    #if(Fade) fade_distance 2 fade_power 2 #end
  }

  union {
   object { Ls }
   object { Ls translate .5*x }
   object { Ls translate x }
   object { Ls translate 1.5*x }
   object { Ls translate -.5*x }
   object { Ls translate -x }
   object { Ls translate -1.5*x }
   translate y
  }

 #break
 #case(2)

  light_source{
    y
    1
    area_light 3*x, z, 7, 1
    #if(Fade) fade_distance 2 fade_power 2 #end
  }

 #break
 #case(3)

  light_source{
    y
    1
    area_light 3*x, z, 7, 1
    #if(Fade) fade_distance 2 fade_power 2 #end
    area_illumination on
  }

 #break

#end

cylinder { <0, .01, 0>, <0, 5, 0>, 2 pigment { rgbt 1 } hollow no_shadow
 interior {
  media {
   #if(Media = 1) scattering {Type, 30 } #end
   #if(Media = 2) emission 2 #end
   #if(Media = 3) absorption 2 #end
    density { cylindrical turbulence 1.5 scale <1, .14, 1> }
  }
 }
 scale <.15, 1, .4> translate 4*z
}

plane { y,0 pigment { rgb .7 } }
plane { -z,-7 pigment { gradient y color_map { [.5 rgb 1][.5 rgb 0] } } }
union {
 sphere { 0,.05 }
 sphere { .5*x,.05 }
 sphere { x,.05 }
 sphere { 1.5*x,.05 }
 sphere { -.5*x,.05 }
 sphere { -x,.05 }
 sphere { -1.5*x,.05 }
 translate y
  hollow pigment { rgbt 1 } interior { media { emission 10 } }
}

Comments:


Comment by Simon (infoised) - Wednesday, 01 May 2013, 18:32 GMT+5

Well emission has nothing to do with lights, and absorption creates shadows and obscures what's behind, but does not shine under light. So scattering is the only one affected by attenuation.

I found where the problem is in the code.

Function MediaFunction::ComputeOneMediaSample calculates the light colour by calling Trace::TestShadow This function then calls Trace::ComputeOneLightRay where you see the comment 'for full area lighting we apply distance- and angle-based attenuation to each "lightlet" individually later'

but TestShadow function never does that (never goes recursively into full area lighting, it treats the area light as a single point source). A simple solution is to just add attenuation in TestShadow after calling the ComputeOneLightRay function. Basically, two lines of code must be copied from ComputeOneLightRay into TestShadow. Or a more long term solution, Ray object should have a flag that signals that it is meant for media calculation. This flag can then be tested in ComputeOneLightRay.

Do we want area_illumination to apply to scattering media? It should not be default, because this would make area_illumination extremely slow. But it could be the user's choice.

This will not affect anything else. Trace::TestShadow is ONLY USED FOR SCATTERING MEDIA - it appears nowhere else in the code.

wfpokorny avatar Feb 01 '17 14:02 wfpokorny