POV-Ray : Newsgroups : povray.bugreports : Light beam won't refract from outside media container Server Time
28 Aug 2025 16:16:29 EDT (-0400)
  Light beam won't refract from outside media container (Message 1 to 3 of 3)  
From: Cousin Ricky
Subject: Light beam won't refract from outside media container
Date: 24 Aug 2025 13:16:57
Message: <68ab4909@news.povray.org>
A cylindrical beam does not refract through media unless the light
source is inside the media container.  In the attached frame 1, the
light source is below the media container, just outside the bottom of
the image.  In frame 2, the light source is inside the media container.

---%<-----%<-----%<-----%<---[BEGIN CODE]---%<-----%<-----%<-----%<---
#version max (3.7, min (3.8, version));

global_settings
{ assumed_gamma 1
  max_trace_level 50
  photons { spacing 0.05 autostop 0 media 100 }
}

#declare HALFH = 5;
#declare HALFW = HALFH * 4/3;
#declare DCAM = 25;
camera
{ location vrotate (-DCAM * z, -6 * x)
  look_at 0
  right 4/3 * x
  angle 2 * degrees (atan2 (HALFW, DCAM))
}

box
{ <-HALFW, -HALFH, -6.01>, <HALFW, HALFH, 0.01>
  hollow
  pigment { rgbt 1 }
  interior
  { media
    { scattering { 1, 1 extinction 0 }
      method 3
      intervals 1
      samples 3, 3
      aa_level 2
    }
  }
}

light_source
{ <0, frame_number * 2 - 3 - HALFH, -3>, rgb 1
  cylinder radius 0.4 falloff 0.4
  parallel point_at <0, 0, -3>
}

prism
{ 0, 6, 4,
  <-1, 0>, <1, 1>, <1, -1>, <-1, 0>
  hollow
  rotate -90 * x
  scale <1.5, 1.5, 1>
  texture
  { pigment { rgbf 1 }
    finish { reflection { 1 fresnel } conserve_energy }
  }
  interior { ior 1.5 }
  photons { target collect off reflection on refraction on }
}
--->%----->%----->%----->%----[END CODE]---->%----->%----->%----->%---


Post a reply to this message


Attachments:
Download 'media_refraction1.jpg' (6 KB) Download 'media_refraction2.jpg' (7 KB)

Preview of image 'media_refraction1.jpg'
media_refraction1.jpg

Preview of image 'media_refraction2.jpg'
media_refraction2.jpg


 

From: William F Pokorny
Subject: Re: Light beam won't refract from outside media container
Date: 25 Aug 2025 13:29:42
Message: <68ac9d86@news.povray.org>
On 8/24/25 13:16, Cousin Ricky wrote:
> A cylindrical beam does not refract through media unless the light
> source is inside the media container.

Thanks for the example scene!

First, when using scattering media / photons the light source must start 
outside any media container by at least some epsilon amount. Some years 
ago there was a long-ish news thread about this being how POV-Ray has 
long worked. (Yes, it seems like for the cylindrical light source this 
rule is 'somewhat' of a lie for the scattering media calculations... 
News to me.)

Second, when tracing photons through a transparent box, the box itself 
needs a photon{} block with 'reflection on' and 'refraction on'. 
Otherwise, the forward photon tracing stops at that first media-box 
surface. This is why it 'looks like' refraction is not working when the 
light's origin is outside the media-box.

Third, You've got 'hollow on' for the prism. Depending on what you want 
for a result, this can be an OK thing to do. When on, it does mean the 
prism surfaces are treated as infinitely thin surfaces and the 
scattering media (Less, certain, light source settings) is calculated 
inside the prism as if it contains the box's media for both the 
scattering result and photon, media depositions. Using 'hollow off' 
would be more 'realistic' for your scene's set up for the scattering 
contribution.

Fourth, the scattering media result is unrealistic in the original scene 
  given there is refraction. The scattering calculation is done in a 
backward tracing way. To turn off the scattering result you can add 
'media_interaction off' to the light source.

In the attached multi-image, image, the left column is the frame 1 set 
up, and the right column frame 2's. In all results the prism is using 
'hollow off' and a 'photons 'target collect off reflection on refraction 
on } block is used for the media-box.

The top row shows only the scattering media result (no photons).

In the middle row both the scattering and photons contributions.

In the bottom row the scattering calculation is dropped by using 'media 
interaction off' in the light_source{} block.

Yes! There should be some refraction/refection contributions looking 
into the top of the prism coming from the media photons outside the 
prism. We can get those back by using 'hollow on' - as you originally 
did - for the prism while still using 'media_interaction off' with the 
light source. See the larger of the attached images.

Bill P.


Post a reply to this message


Attachments:
Download 'rickyfractionpuzzle.png' (14 KB) Download 'rickyfractionpuzzle_story.png' (46 KB)

Preview of image 'rickyfractionpuzzle.png'
rickyfractionpuzzle.png

Preview of image 'rickyfractionpuzzle_story.png'
rickyfractionpuzzle_story.png


 

From: William F Pokorny
Subject: Re: Light beam won't refract from outside media container
Date: 25 Aug 2025 14:02:56
Message: <68aca550@news.povray.org>
On 8/25/25 13:29, William F Pokorny wrote:
> Yes! There should be some refraction/refection contributions looking 
> into the top of the prism coming from the media photons outside the 
> prism. We can get those back by using 'hollow on' - as you originally 
> did - for the prism while still using 'media_interaction off' with the 
> light source. See the larger of the attached images.

Apologies. I grabbed the wrong image for the larger one mentioned 
above... Hopefully the correct one is now attached.

Bill P.


Post a reply to this message


Attachments:
Download 'rickyfractionpuzzle.png' (67 KB)

Preview of image 'rickyfractionpuzzle.png'
rickyfractionpuzzle.png


 

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