mirror and mixfunc

Hi all,

I got stuck a bit applying mixfunc and mirror material. It seems that the check for secondary light sources is partly disabled when applying (at least I assume so).

A simple example:

lets assume an ideal mirror

void mirror testmat1
0
3 1 1 1

If I use just this material on a surface and start an rtrace sending to the surface, then I get the correct result for both options - either rtrace or rtrace -I. So far so good.

In case I use a (stupid, but simple) mixfunc:

void mixfunc test_mix
4 testmat1 testmat1 0.5 .
0

I should get the same result, since I'm mixing the same material with a fixed value.
But: rtrace -I delivers only 0, whereas rtrace delivers the correct value. So it seems that mixfunc cannot be applied with mirror, when the -I option is used. Or I did something wrong?
I used -dr 2 and -dt 0 in both cases.

Of course my ultimate goal is not mixing that simple but mixing two different material types, also depending on the angle of incidence, but this simple example shows the principle problem.

Is there any solution using mixfunc and mirror when using rtrace -I ?

Jan

···

--
Dr.-Ing. Jan Wienold
Ecole Polytechnique Fédérale de Lausanne (EPFL)
EPFL ENAC IA LIPID

http://people.epfl.ch/jan.wienold
LE 1 111 (Office)
Phone +41 21 69 30849

Hi Jan,

As you discovered, the code isn't sophisticated enough to handle virtual source materials (mirror, prism, prism2) through the mixfunc interface. (BTW, mixfunc also fails for light sources.) However, you can use the "alternate material" argument to the mirror primitive to specify a different behavior for when the mirror is not directly participating in the virtual source relay calculation. You could have a chain like this, which would work:

void metal mat1
[arguments]

void plastic mat2
[arguments]

void mixfunc mat1+2
4 mat1 mat2 mixing_var mixit.cal
0
0

void mirror mmat1+2
1 mat1+2
0
3 .5 .5 .5

···

------
When the mirror material is participating in the virtual source calculation, it reflects everything at 50%. When it's participating in the interreflection calculation, or you look at it directly, then it switches to the mixfunc mat1+2's behavior.

If one of your goals is to have the mixfunc control the amount of reflected light in the virtual calculation, I'm afraid you will need to use a brightfunc modifier on the mirror material, instead. You can do this in conjunction with an alternate material to make the behavior consistent if you like. In the example above, let's say that mat1 is mirror-like with 80% reflectance and mat2 is diffusing. You could use the same cal file for your brightfunc, modifying the mirror primitive like so:

void brightfunc mir_amt
2 mixing_var mixit.cal
0
0

mir_amt mirror mmat1+2
1 mat1+2
0
3 .8 .8 .8

--------
Does this make sense?

-Greg

From: Jan Wienold <[email protected]>
Subject: [Radiance-general] mirror and mixfunc
Date: December 1, 2015 6:44:00 AM PST

Hi all,

I got stuck a bit applying mixfunc and mirror material. It seems that the check for secondary light sources is partly disabled when applying (at least I assume so).

A simple example:

lets assume an ideal mirror

void mirror testmat1
0
0
3 1 1 1

If I use just this material on a surface and start an rtrace sending to the surface, then I get the correct result for both options - either rtrace or rtrace -I. So far so good.

In case I use a (stupid, but simple) mixfunc:

void mixfunc test_mix
4 testmat1 testmat1 0.5 .
0
0

I should get the same result, since I'm mixing the same material with a fixed value.
But: rtrace -I delivers only 0, whereas rtrace delivers the correct value. So it seems that mixfunc cannot be applied with mirror, when the -I option is used. Or I did something wrong?
I used -dr 2 and -dt 0 in both cases.

Of course my ultimate goal is not mixing that simple but mixing two different material types, also depending on the angle of incidence, but this simple example shows the principle problem.

Is there any solution using mixfunc and mirror when using rtrace -I ?

Jan

I love when Greg shares these kung foo tips and deep insights to Radiance's
underbelly, and then closes with "Does this make sense". Yes, it makes
sense, after reading it like five times. Thanks, Greg, as always!

···

On Tue, Dec 1, 2015 at 9:51 AM, Greg Ward <[email protected]> wrote:

Hi Jan,

As you discovered, the code isn't sophisticated enough to handle virtual
source materials (mirror, prism, prism2) through the mixfunc interface.
(BTW, mixfunc also fails for light sources.) However, you can use the
"alternate material" argument to the mirror primitive to specify a
different behavior for when the mirror is not directly participating in the
virtual source relay calculation. You could have a chain like this, which
would work:

void metal mat1
[arguments]

void plastic mat2
[arguments]

void mixfunc mat1+2
4 mat1 mat2 mixing_var mixit.cal
0
0

void mirror mmat1+2
1 mat1+2
0
3 .5 .5 .5

------
When the mirror material is participating in the virtual source
calculation, it reflects everything at 50%. When it's participating in the
interreflection calculation, or you look at it directly, then it switches
to the mixfunc mat1+2's behavior.

If one of your goals is to have the mixfunc control the amount of
reflected light in the virtual calculation, I'm afraid you will need to use
a brightfunc modifier on the mirror material, instead. You can do this in
conjunction with an alternate material to make the behavior consistent if
you like. In the example above, let's say that mat1 is mirror-like with
80% reflectance and mat2 is diffusing. You could use the same cal file for
your brightfunc, modifying the mirror primitive like so:

void brightfunc mir_amt
2 mixing_var mixit.cal
0
0

mir_amt mirror mmat1+2
1 mat1+2
0
3 .8 .8 .8

--------
Does this make sense?

-Greg

> From: Jan Wienold <[email protected]>
> Subject: [Radiance-general] mirror and mixfunc
> Date: December 1, 2015 6:44:00 AM PST
>
> Hi all,
>
> I got stuck a bit applying mixfunc and mirror material. It seems that
the check for secondary light sources is partly disabled when applying (at
least I assume so).
>
> A simple example:
>
> lets assume an ideal mirror
>
> void mirror testmat1
> 0
> 0
> 3 1 1 1
>
> If I use just this material on a surface and start an rtrace sending to
the surface, then I get the correct result for both options - either rtrace
or rtrace -I. So far so good.
>
> In case I use a (stupid, but simple) mixfunc:
>
> void mixfunc test_mix
> 4 testmat1 testmat1 0.5 .
> 0
> 0
>
> I should get the same result, since I'm mixing the same material with a
fixed value.
> But: rtrace -I delivers only 0, whereas rtrace delivers the correct
value. So it seems that mixfunc cannot be applied with mirror, when the -I
option is used. Or I did something wrong?
> I used -dr 2 and -dt 0 in both cases.
>
> Of course my ultimate goal is not mixing that simple but mixing two
different material types, also depending on the angle of incidence, but
this simple example shows the principle problem.
>
> Is there any solution using mixfunc and mirror when using rtrace -I ?
>
> Jan

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

The idea is to create a simple mirror, a ‘caustic’ effect and apply a pattern to it, to create holes without having to modify the geometry.
The geometry is a classic:
cap.rad - the cap for the ring
mix ring top
0
0
8
0 0 25
0 0 1
57.29432507 60
scene.rad - a spot light and a plane
void spotlight spot
0
0
7 50000 50000 50000 35 0 -1 -1
spot sphere source
0
0
4 0 200 200 2.5
void plastic white
0
0
5 .5 .5 .5 0 0
white polygon plan
0
0
12
-500 -500 0
-500 500 0
500 500 0
500 -500 0
single.rad - a single sector of the ring, to array
mix polygon int
0
0
12
-.5 -57.29432507 0
-.5 -57.29432507 25
.5 -57.29432507 25
.5 -57.29432507 0
mix polygon ext
0
0
12
-.5237120674 -60 0
.5237120674 -60 0
.5237120674 -60 25
-.5237120674 -60 25
And now the interesting stuff:
To activate secondary sources use -dr N (N>0).
We will use mirror.
Unfortunately when mirror is nested into a mixfunc material is invisible to the secondary source tracer... but there is a workaround...
model.mat
#alterate the reflectance of the metal - optional
void brightfunc stripes
2 'sin(A1*Pz)' .
0
1 .8
#metal
stripes metal metal
0
0
5 .8 .8 .8 0.001 0
#mix the metal with void to create holes
void mixfunc strip
4 metal void 'if(sin(A1*Py),0,1)' .
0
1 .2
#alterate the reflectance of mirror, reflectance is 0% for holes
void brightfunc band
2 'if(sin(A1*Py),0,1)' .
0
1 .2
#mirror attached to the metal surface, with holes
band mirror mix
1 strip
0
3 1 1 1

Now, array the single.rad file:
xform -a 360 -rz 1 -i 1 single.rad > ring.rad

···

From my old blog….

On 1 Dec 2015, at 16:51, Greg Ward <[email protected]> wrote:

Hi Jan,

As you discovered, the code isn't sophisticated enough to handle virtual source materials (mirror, prism, prism2) through the mixfunc interface. (BTW, mixfunc also fails for light sources.) However, you can use the "alternate material" argument to the mirror primitive to specify a different behavior for when the mirror is not directly participating in the virtual source relay calculation. You could have a chain like this, which would work:

void metal mat1
[arguments]

void plastic mat2
[arguments]

void mixfunc mat1+2
4 mat1 mat2 mixing_var mixit.cal
0
0

void mirror mmat1+2
1 mat1+2
0
3 .5 .5 .5

------
When the mirror material is participating in the virtual source calculation, it reflects everything at 50%. When it's participating in the interreflection calculation, or you look at it directly, then it switches to the mixfunc mat1+2's behavior.

If one of your goals is to have the mixfunc control the amount of reflected light in the virtual calculation, I'm afraid you will need to use a brightfunc modifier on the mirror material, instead. You can do this in conjunction with an alternate material to make the behavior consistent if you like. In the example above, let's say that mat1 is mirror-like with 80% reflectance and mat2 is diffusing. You could use the same cal file for your brightfunc, modifying the mirror primitive like so:

void brightfunc mir_amt
2 mixing_var mixit.cal
0
0

mir_amt mirror mmat1+2
1 mat1+2
0
3 .8 .8 .8

--------
Does this make sense?

-Greg

From: Jan Wienold <[email protected]>
Subject: [Radiance-general] mirror and mixfunc
Date: December 1, 2015 6:44:00 AM PST

Hi all,

I got stuck a bit applying mixfunc and mirror material. It seems that the check for secondary light sources is partly disabled when applying (at least I assume so).

A simple example:

lets assume an ideal mirror

void mirror testmat1
0
0
3 1 1 1

If I use just this material on a surface and start an rtrace sending to the surface, then I get the correct result for both options - either rtrace or rtrace -I. So far so good.

In case I use a (stupid, but simple) mixfunc:

void mixfunc test_mix
4 testmat1 testmat1 0.5 .
0
0

I should get the same result, since I'm mixing the same material with a fixed value.
But: rtrace -I delivers only 0, whereas rtrace delivers the correct value. So it seems that mixfunc cannot be applied with mirror, when the -I option is used. Or I did something wrong?
I used -dr 2 and -dt 0 in both cases.

Of course my ultimate goal is not mixing that simple but mixing two different material types, also depending on the angle of incidence, but this simple example shows the principle problem.

Is there any solution using mixfunc and mirror when using rtrace -I ?

Jan

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Thanks, Giulio, great stuff! Do we have a link to your blog from radiance-online? We should add one if we don't. Is there an index of any kind?

Cheers,
-Greg

···

From: giulioandrea antonutto foi <[email protected]>
Subject: Re: [Radiance-general] mirror and mixfunc
Date: December 1, 2015 8:57:52 AM PST

From my old blog….

The idea is to create a simple mirror, a ‘caustic’ effect and apply a pattern to it, to create holes without having to modify the geometry.
The geometry is a classic:
cap.rad - the cap for the ring
mix ring top
0
0
8
0 0 25
0 0 1
57.29432507 60
scene.rad - a spot light and a plane
void spotlight spot
0
0
7 50000 50000 50000 35 0 -1 -1
spot sphere source
0
0
4 0 200 200 2.5
void plastic white
0
0
5 .5 .5 .5 0 0
white polygon plan
0
0
12
-500 -500 0
-500 500 0
500 500 0
500 -500 0
single.rad - a single sector of the ring, to array
mix polygon int
0
0
12
-.5 -57.29432507 0
-.5 -57.29432507 25
.5 -57.29432507 25
.5 -57.29432507 0
mix polygon ext
0
0
12
-.5237120674 -60 0
.5237120674 -60 0
.5237120674 -60 25
-.5237120674 -60 25
And now the interesting stuff:
To activate secondary sources use -dr N (N>0).
We will use mirror.
Unfortunately when mirror is nested into a mixfunc material is invisible to the secondary source tracer... but there is a workaround...
model.mat
#alterate the reflectance of the metal - optional
void brightfunc stripes
2 'sin(A1*Pz)' .
0
1 .8
#metal
stripes metal metal
0
0
5 .8 .8 .8 0.001 0
#mix the metal with void to create holes
void mixfunc strip
4 metal void 'if(sin(A1*Py),0,1)' .
0
1 .2
#alterate the reflectance of mirror, reflectance is 0% for holes
void brightfunc band
2 'if(sin(A1*Py),0,1)' .
0
1 .2
#mirror attached to the metal surface, with holes
band mirror mix
1 strip
0
3 1 1 1

Now, array the single.rad file:
xform -a 360 -rz 1 -i 1 single.rad > ring.rad

...

Hi Greg and Giulio,

thanks for your cool (kung foo:-) ) tips! And yes it totally makes sense! :slight_smile:

About the brightfunc I was already aware, but I couldn't find a solution to integrate a material for the interreflection calculation. I was already thinking of running two times with different material definitions, but this is a cool solution!

Jan

···

Am 12/1/15 um 5:56 PM schrieb Rob Guglielmetti:

I love when Greg shares these kung foo tips and deep insights to Radiance's underbelly, and then closes with "Does this make sense". Yes, it makes sense, after reading it like five times. Thanks, Greg, as always!

On Tue, Dec 1, 2015 at 9:51 AM, Greg Ward <[email protected] > <mailto:[email protected]>> wrote:

    Hi Jan,

    As you discovered, the code isn't sophisticated enough to handle
    virtual source materials (mirror, prism, prism2) through the
    mixfunc interface. (BTW, mixfunc also fails for light sources.) However, you can use the "alternate material" argument to the
    mirror primitive to specify a different behavior for when the
    mirror is not directly participating in the virtual source relay
    calculation. You could have a chain like this, which would work:

    void metal mat1
    [arguments]

    void plastic mat2
    [arguments]

    void mixfunc mat1+2
    4 mat1 mat2 mixing_var mixit.cal
    0

    void mirror mmat1+2
    1 mat1+2
    0
    3 .5 .5 .5

    ------
    When the mirror material is participating in the virtual source
    calculation, it reflects everything at 50%. When it's
    participating in the interreflection calculation, or you look at
    it directly, then it switches to the mixfunc mat1+2's behavior.

    If one of your goals is to have the mixfunc control the amount of
    reflected light in the virtual calculation, I'm afraid you will
    need to use a brightfunc modifier on the mirror material,
    instead. You can do this in conjunction with an alternate
    material to make the behavior consistent if you like. In the
    example above, let's say that mat1 is mirror-like with 80%
    reflectance and mat2 is diffusing. You could use the same cal
    file for your brightfunc, modifying the mirror primitive like so:

    void brightfunc mir_amt
    2 mixing_var mixit.cal
    0

    mir_amt mirror mmat1+2
    1 mat1+2
    0
    3 .8 .8 .8

    --------
    Does this make sense?

    -Greg

    > From: Jan Wienold <[email protected] <mailto:[email protected]>>
    > Subject: [Radiance-general] mirror and mixfunc
    > Date: December 1, 2015 6:44:00 AM PST
    >
    > Hi all,
    >
    > I got stuck a bit applying mixfunc and mirror material. It seems
    that the check for secondary light sources is partly disabled when
    applying (at least I assume so).
    >
    > A simple example:
    >
    > lets assume an ideal mirror
    >
    > void mirror testmat1
    > 0
    > 3 1 1 1
    >
    > If I use just this material on a surface and start an rtrace
    sending to the surface, then I get the correct result for both
    options - either rtrace or rtrace -I. So far so good.
    >
    > In case I use a (stupid, but simple) mixfunc:
    >
    > void mixfunc test_mix
    > 4 testmat1 testmat1 0.5 .
    > 0
    >
    > I should get the same result, since I'm mixing the same material
    with a fixed value.
    > But: rtrace -I delivers only 0, whereas rtrace delivers the
    correct value. So it seems that mixfunc cannot be applied with
    mirror, when the -I option is used. Or I did something wrong?
    > I used -dr 2 and -dt 0 in both cases.
    >
    > Of course my ultimate goal is not mixing that simple but mixing
    two different material types, also depending on the angle of
    incidence, but this simple example shows the principle problem.
    >
    > Is there any solution using mixfunc and mirror when using rtrace
    -I ?
    >
    > Jan

    _______________________________________________
    Radiance-general mailing list
    [email protected]
    <mailto:[email protected]>
    http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

--
Dr.-Ing. Jan Wienold
Ecole Polytechnique F�d�rale de Lausanne (EPFL)
EPFL ENAC IA LIPID

LE 1 111 (Office)
Phone +41 21 69 30849

Unfortunately is no more online but I still have some of the entries.
I can probably make a PDF of these and send it to Andy for sharing with the community?
G.

···

On 1 Dec 2015, at 17:11, Greg Ward <[email protected]> wrote:

Thanks, Giulio, great stuff! Do we have a link to your blog from radiance-online? We should add one if we don't. Is there an index of any kind?

Cheers,
-Greg

From: giulioandrea antonutto foi <[email protected] <mailto:[email protected]>>
Subject: Re: [Radiance-general] mirror and mixfunc
Date: December 1, 2015 8:57:52 AM PST

From my old blog….

The idea is to create a simple mirror, a ‘caustic’ effect and apply a pattern to it, to create holes without having to modify the geometry.
The geometry is a classic:
cap.rad - the cap for the ring
mix ring top
0
0
8
0 0 25
0 0 1
57.29432507 60
scene.rad - a spot light and a plane
void spotlight spot
0
0
7 50000 50000 50000 35 0 -1 -1
spot sphere source
0
0
4 0 200 200 2.5
void plastic white
0
0
5 .5 .5 .5 0 0
white polygon plan
0
0
12
-500 -500 0
-500 500 0
500 500 0
500 -500 0
single.rad - a single sector of the ring, to array
mix polygon int
0
0
12
-.5 -57.29432507 0
-.5 -57.29432507 25
.5 -57.29432507 25
.5 -57.29432507 0
mix polygon ext
0
0
12
-.5237120674 -60 0
.5237120674 -60 0
.5237120674 -60 25
-.5237120674 -60 25
And now the interesting stuff:
To activate secondary sources use -dr N (N>0).
We will use mirror.
Unfortunately when mirror is nested into a mixfunc material is invisible to the secondary source tracer... but there is a workaround...
model.mat
#alterate the reflectance of the metal - optional
void brightfunc stripes
2 'sin(A1*Pz)' .
0
1 .8
#metal
stripes metal metal
0
0
5 .8 .8 .8 0.001 0
#mix the metal with void to create holes
void mixfunc strip
4 metal void 'if(sin(A1*Py),0,1)' .
0
1 .2
#alterate the reflectance of mirror, reflectance is 0% for holes
void brightfunc band
2 'if(sin(A1*Py),0,1)' .
0
1 .2
#mirror attached to the metal surface, with holes
band mirror mix
1 strip
0
3 1 1 1

Now, array the single.rad file:
xform -a 360 -rz 1 -i 1 single.rad > ring.rad

...

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general