POV-Ray : Newsgroups : povray.general : Refraction patterns Server Time: 23 Oct 2019 03:24:54 GMT
 Refraction patterns (Message 1 to 8 of 8)
 From: IGM Subject: Refraction patterns Date: 1 Oct 2019 10:40:01 Message:
```Hello,
media { density {} } allows a 3D distribution of absorbace. This will change
each ray intensity. Is it possible to have a 3D distribution of the refractive
index? This would allow the bending of each ray _inside_ the material. At the
moment, in povray, bending of rays is possible only on the surface, through the
real geometry of the object or through the normal {} command.

An example of the possible effects of ior 3D patterns is the "Fata Morgana" (
https://en.wikipedia.org/wiki/Fata_Morgana_(mirage) ) and other atmospheric
effects. Also ancient or low quality real glasses show this effect. GRIN lenses
are another example.

How would you produce a non-uniform distribution of the refractive index, in the
absence of a interior {ior density {}} command?

Thanks
igmar
```
 From: William F Pokorny Subject: Re: Refraction patterns Date: 1 Oct 2019 13:17:39 Message: <5d9351f3\$1@news.povray.org>
```On 10/1/19 6:36 AM, IGM wrote:
> Hello,
> media { density {} } allows a 3D distribution of absorbace. This will change
> each ray intensity. Is it possible to have a 3D distribution of the refractive
> index? This would allow the bending of each ray _inside_ the material. At the
> moment, in povray, bending of rays is possible only on the surface, through the
> real geometry of the object or through the normal {} command.
>
> An example of the possible effects of ior 3D patterns is the "Fata Morgana" (
> https://en.wikipedia.org/wiki/Fata_Morgana_(mirage) ) and other atmospheric
> effects. Also ancient or low quality real glasses show this effect. GRIN lenses
> are another example.
>
> How would you produce a non-uniform distribution of the refractive index, in the
> absence of a interior {ior density {}} command?
>
> Thanks
> igmar
>
Short answer, no. Today there is not a way to do this except by creating
lots of surfaces with differing interior IORs - and that's mostly not
practical(1).

---
Answering a similar question some time back, Christoph hinted it might
be doable as a feature, but I'm not sure what he had in mind.

In github comments I've mentioned the idea of supporting interiors apart
from the surface intersections. In other words, interiors (and so IORs)
would be specified by containing shapes (or by patterns/functions)
different from those defining the surface intersections. The aim being
better ways to define things like a glass full of juice without the
coincident surface / surface ordering issues that we fight today. But,
I've only gotten as far as thought experiments and some scribbling on
paper. Such a feature would still depend upon many surfaces - but would
allow for IOR distributions by function/pattern.

Bill P.

(1) - I think some sort of ray stepping is necessary for real
distributed/variable IOR support. It would be slow. Something where all
rays shot are of only short, definable, lengths. A chain ray-jumps end
to end adjusting direction at each step by a sampled IOR.  Moving from
camera to surface, surface to surface, light to surface. Doing this in
conjunction with media sampling, say... I don't know how practical it
would be to do or use in the end.

Parts of a stepped approach could probably be gotten to with animation,
the v38 user-defined camera and  code to handle the ray steps (each
steps IOR adjustment) for limited situations - maybe. Faking whatever
effect your after some other way very likely easier.
```
 From: IGM Subject: Re: Refraction patterns Date: 1 Oct 2019 14:20:00 Message:
```Your comment about ray subdivision and stepping led me to think of a first
approximation to the problem: any object could be subdivided in a certain amount
of small volumes (cubes? 3D voronoi cells?), each with different ior; something
similar to FEM analysis. With small enough cells, or small enough ior
differences, focal_blur could help giving continuity to the whole object. This
approach can be done without adding new features to povray. User has the
freedom to choose the right cells dimensions (ie.e degree of approximation) for
his specific scene.

> In other words, interiors (and so IORs)
> would be specified by containing shapes (or by patterns/functions)
> different from those defining the surface intersections. The aim being
> better ways to define things like a glass full of juice without the
> coincident surface / surface ordering issues that we fight today.

I'm not a C programmer, and therefore (unfortunately) I cannot help in the deep
povray development. However, I'm an optical designer, and I work with Zemax
OpticStudio. In Zemax, the "coincident surface / surface ordering issues" is
solved in this way: any time two surfaces are coincident, the properties
governing the scene are those of the surface defined for *last*. I don't know if
this could help...

Thank you!
igmar
```
 From: Bald Eagle Subject: Re: Refraction patterns Date: 1 Oct 2019 17:40:05 Message:
```Iari,

Could you design a solid lens whose shape gives you the desired effect, and then
apply the no_image modifier?

http://www.povray.org/documentation/view/3.6.1/328/

Then you could have whatever other things you want in the scene, but the
ray-bending lens won't be visible, creating the illusion of a refractive
material.
```
 From: IGM Subject: Re: Refraction patterns Date: 2 Oct 2019 07:25:01 Message:
```"Bald Eagle" <cre### [at] netscapenet> wrote:
> Could you design a solid lens whose shape gives you the desired effect, and then
> apply the no_image modifier?
> [...]
> Then you could have whatever other things you want in the scene, but the
> ray-bending lens won't be visible, creating the illusion of a refractive
> material.

Yes, a standard lens would simulate a roto-symmetric distribution of refractive
index. A polynomial lens or freeform lens would allow a more complex pattern.
Instead, for my application, I was looking for a random distribution of ior with
strong variation inside the pattern, something similar to a smoke, granite or
fractal distribution.
```
 From: Alain Martel Subject: Re: Refraction patterns Date: 2 Oct 2019 19:47:02 Message: <5d94feb6\$1@news.povray.org>
```Le 2019-10-01 Ã  06:36, IGM a Ã©critÂ :
> Hello,
> media { density {} } allows a 3D distribution of absorbace. This will change
> each ray intensity. Is it possible to have a 3D distribution of the refractive
> index? This would allow the bending of each ray _inside_ the material. At the
> moment, in povray, bending of rays is possible only on the surface, through the
> real geometry of the object or through the normal {} command.
>
> An example of the possible effects of ior 3D patterns is the "Fata Morgana" (
> https://en.wikipedia.org/wiki/Fata_Morgana_(mirage) ) and other atmospheric
> effects. Also ancient or low quality real glasses show this effect. GRIN lenses
> are another example.
>
> How would you produce a non-uniform distribution of the refractive index, in the
> absence of a interior {ior density {}} command?
>
> Thanks
> igmar
>
>

NOT possible  now, and maybe never.

It may be possible using an heavily modified render engine.
It would require sampling the IOR gradient amplitude and direction at
multiple locations along a ray. After each test, the direction of each
ray would need to be adjusted. This will affect the location of the nest
sample point.
It would be extremely computationally intensive and bring the render
speed to a crawl.
```
 From: William F Pokorny Subject: Re: Refraction patterns Date: 6 Oct 2019 18:13:27 Message: <5d9a2ec7\$1@news.povray.org>
```On 10/1/19 10:18 AM, IGM wrote:
> Your comment about ray subdivision and stepping led me to think of a first
> approximation to the problem: any object could be subdivided in a certain amount
> of small volumes (cubes? 3D voronoi cells?), each with different ior; something
> similar to FEM analysis. With small enough cells, or small enough ior
> differences, focal_blur could help giving continuity to the whole object. This
> approach can be done without adding new features to povray. User has the
> freedom to choose the right cells dimensions (ie.e degree of approximation) for
> his specific scene.

My mind keeps drifting back to this...

Maybe what you outline couple be a part of some tooling for what you
want. Might be better though to have some interpolation between the
values on the IOR value representation side rather than "smoothing"
after. Better too if the IOR value samples sparse - I'm thinking of a
question years ago on how to represent point charge and equal-potential
regions - a kind of voronoi cell structure but something which
potentially could adjust the number of surfaces. Even better if the IOR
representation doesn't need to be representative values but rather as
simpler gradients / more flexible functions. I think any approach is
going to be inaccurate to a degree no matter what.

Thinking too an isosurface based upon functions a path to representing
many surfaces no requiring they all exist prior. If it can be sorted
might be able to also change the density of refractive surfaces based
upon whether locally the ior is changing much. Surfaces aside we need
some ability to represent the IORs at the surface variably - something
set on each intersection.

Had the thought during the past days that, given you want tracing
through complicated IOR distributions, just stepping short rays in one
direction probably not enough. With distributions - rippling waves of
heat off objects or whatever - it likely happens light rays/paths wander
all over and sometimes locally converge / run over each other in ways
phase and interference matters. In other words, at the camera you don't
really know what light rays from the shape will land on the screen so to
speak. To capture that would require reverse tracing from the shape(s)
you want to 'see' through the IOR distribution without knowledge of
whether of those rays matter to the resultant image in the end.

>
>> In other words, interiors (and so IORs)
>> would be specified by containing shapes (or by patterns/functions)
>> different from those defining the surface intersections. The aim being
>> better ways to define things like a glass full of juice without the
>> coincident surface / surface ordering issues that we fight today.
>
> I'm not a C programmer, and therefore (unfortunately) I cannot help in the deep
> povray development. However, I'm an optical designer, and I work with Zemax
> OpticStudio. In Zemax, the "coincident surface / surface ordering issues" is
> solved in this way: any time two surfaces are coincident, the properties
> governing the scene are those of the surface defined for *last*. I don't know if
> this could help...

Suppose my initial thought is no, but maybe I don't understand what
Zemax is really doing with ordering from what you said.

In a ray tracer the direction of rays is well defined, but not with
respect to any global scene direction. With a glass of juice I have a
shape for the container and a shape shape for the juice. Suppose I
define a glass -> juice shape order by time defined, an assigned numeric
priority or by position relative to some otherwise defined scene direction.

A ray entering in a glass to juice direction gets sorted properly
because I set a glass -> juice ordering. What happens on the other side
of the glass? I need there a juice -> glass ordering. What happens for
rays coming in from the top of my drink where again I need a juice ->
glass ordering. What about internally reflected rays to the juice or
glass IOR?

I can envision 'complicated' book keeping somehow sorting out when to
flip the user orders at each intersection, but such an approach seems
very messy. Especially given that we have, already, numerical issues at
truly coincident surfaces that require we roll up multiple intersections
within some numerical tolerance before applying any kind of defined use
order to the collection of intersections.

With opaque surfaces, defining some order perhaps hard sets what
textures we get on coincidence surfaces - always one over the other no
matter ray direction. With any transparency, it looks complicated to me
- user definable ordering or not.

Zemax I suppose handles these complications. Or maybe there is internal
detail not understood/described. Or maybe I just don't see how a defined
order simplifies things(1a)?

---
What I'd like to get to is interior handling that is not ambiguous in
any way and something which prevents interior overlap(1).

Something which looks for the ior/interior behind and forward of any
'surface only' intersection along with intersections - naturally -
rolling up 'interior only' shapes for inside tests slightly ahead of and
behind the surface intersection defining the IORs at the interface.

Today inside POV-Ray we carry this stack of interiors and track all the
entering and exiting of interiors as the ray moves from surface to
surface. It's messy. It's numerically error prone. It's what causes some
of the bright and dark speckling in images.

FYI. I'm not much of a c++ programmer which hinders my sandbox play.

thought some about myself is interesting.

Bill P.

(1) - As collected by the local set of intersections at any given
surface(1a). With any change to interior handling we should also limit
interior shape intersection depths to what is numerically stable. A near
tangent edges of curved surfaces and the interiors would cease to be
seen where the intersection to intersection depths too close.

(1a) - To represent a bubble inside the juice we would, for example,
have one sphere for the surface/change in ior. Two spheres defining the
interiors - in this case probably duplicates of the surface intersection
sphere where one inverted. And, backing off an earlier, peripheral lie,
defined interiors would have a priority order to - sometimes - simplify
the needed interior containing shapes. Bubbles in juice abutting the
glass surface for example.
```
 From: IGM Subject: Re: Refraction patterns Date: 7 Oct 2019 11:45:00 Message:
```William F Pokorny <ano### [at] anonymousorg> wrote:
> On 10/1/19 10:18 AM, IGM wrote:
> > Your comment about ray subdivision and stepping led me to think of a first
> > approximation to the problem: any object could be subdivided in a certain amount
> > of small volumes (cubes? 3D voronoi cells?), each with different ior; something
> > similar to FEM analysis. With small enough cells, or small enough ior
> > differences, focal_blur could help giving continuity to the whole object. This
> > approach can be done without adding new features to povray. User has the
> > freedom to choose the right cells dimensions (ie.e degree of approximation) for
> > his specific scene.
>
> My mind keeps drifting back to this...
>
> [...]

I realized that this problem is actually extremely complex. I still need
thinking to it and to your suggestions..

> Suppose my initial thought is no, but maybe I don't understand what
> Zemax is really doing with ordering from what you said.

The ordering is not physical, i.e. due to the ray direction/properties: it
simply refers to *the order of the objects in the description of the scene*
(!!). Zemax looks like a spreadsheet: in the list, object 6 defines the
properties eventually ambiguous with object 5 and all the previuos, as in the
case of coincident surfaces. This brutal solution is not physical, but simply
helps the user being consciuos of what's going on, and therefore governing the
system. Taking your example about the juice glass, you can define both solids
(the juice in line 4 and the glass in line 5, we say), and describe the
properties you care (scattering, coatings, and so on..) on the internal surface
of the glass (that is the last object in the description). Any time a ray will
be traced, the software will recognize that, in case of ambiguity, the
properties defined on object in line 5 dominate over those of the previous ones.
```