rtrace: -ospec options

Dear Group

I use Radiance for a few years, and I handled with different problems so far. Now I have to complicated problem and I need some help. I engage in energy transport in participating media (rtrace with parameter –me).

As I read in ‘Rendering with Radiance’ value of expression
L(s) = L(0)*ext-(kappa*s) (assume albedo omega=0) (1)
is computed ‘after all the ray-surface interactions’ (page 591-592)

Is this formula computed for each ray, and then values connected with all rays are added? (it seems to me it is) Or maybe first values for all rays are added and after expression (1) is computed?

I need for my algorithm data connected with single ray: the value L(0) and distance s.

I tried to use rtrace with some options (all parameters are presented below – file: render_h.opt):
- ‘-otl’ – to get the distance from origin to object (s), but I’m not sure if s = l (l – effective length of ray)
- ‘-otv’ – to get value of each ray traced, but I get a table of zero values (something is wrong, I don’t know what)

Is this possible to compute L(0) and s (for each ray traced) using rtrace with some options at all? (I tried to analyze source codes of Radiance programs to find out it, but I’m not a programmer and it’s to complicated to me to understand it)

Best regards
Marcin Gawronski

···

---------------------------

Attachments (my files):

- start: START.BAT

oconv S1.txt > pros.oct
rtrace @render_h.opt -h '-ospec' pros.oct <punktyS1.txt> ou-S1.txt
erase pros.oct
pause

- geometry and materials: S1.txt:

# material o odbiciu 0.2
void plastic odb0.2
0 0 5 0.3 0.3 0.3 0 0
                    
# material o odbiciu 0.3 void plastic odb0.3 0 0 5 0.3 0.3 0.3 0 0
# przypisanie swiecacemu materialowi mat.dist rozkladu rozklad.dat
void brightdata mat.dist 5 noneg rozklad.dat illum.cal il_alth il_azih
0 9 1 0 0 0 -1 0 0 0 -1

# material S1 o odbiciu 0.7 rozkladzie mat.dist
mat.dist illum S1
1 odb0.2 0 3 16737.3478 16737.3478 16737.3478

# source
S1 polygon zrodlo1
0
0 12 0 0 1
  0 1 1
  1 1 1
  1 0 1
                    
odb0.3 polygon nazwa 0 0 12 0 0 0
  0 1 0
  1 1 0
  1 0 0

source distribution (rozklad.dat):
1
1 0 37
    
1

- rtrace parameters: render_h.opt

-dp 4096
-ar 93
-ms 0.03
-ds .05
-dj 0
-dt 0
-dc .75
-dr 3
-sj 1
-st 0
-ab 10
-aa 0.08
-ad 2048
-as 1024
-av 0 0 0
-lr 12
-lw .0005
-I
-me 0.2 0.2 0.2 (if nesessary)

- point: punktyS1.txt
0.1 0.1 0 0 0 0.01

----------------------------------------------------------------------
Sprawdz, czy jestes prawdziwym internauta!
Kliknij http://link.interia.pl/f1d6e

Hi Marcin,

I will try to answer your questions inline, below...

From: Marcin Gawroński <[email protected]>
Date: March 31, 2008 3:51:46 AM PDT

Dear Group

I use Radiance for a few years, and I handled with different problems so far. Now I have to complicated problem and I need some help. I engage in energy transport in participating media (rtrace with parameter –me).

As I read in ‘Rendering with Radiance’ value of expression
L(s) = L(0)*ext-(kappa*s) (assume albedo omega=0) (1)
is computed ‘after all the ray-surface interactions’ (page 591-592)

Is this formula computed for each ray, and then values connected with all rays are added? (it seems to me it is) Or maybe first values for all rays are added and after expression (1) is computed?

This formula is applied for each ray. You can read the code in src/rt/raytrace.c if that helps. Look at the "rayparticipate" function, which is called from "raytrace".

I need for my algorithm data connected with single ray: the value L(0) and distance s.

Can't you use -otvL with -me 0 0 0 in rtrace? This will report the ray length and value for the entire ray tree.

I tried to use rtrace with some options (all parameters are presented below – file: render_h.opt):
- ‘-otl’ – to get the distance from origin to object (s), but I’m not sure if s = l (l – effective length of ray)
- ‘-otv’ – to get value of each ray traced, but I get a table of zero values (something is wrong, I don’t know what)

Only rays that are linked to tree branches that end in glow surfaces or light sources will have non-zero values if -av 0 0 0 (the default) is specified. I suspect the problem in your case is that -me 0.2 0.2 0.2 is so large that ray paths are never short enough to yield a non-zero result.

Is this possible to compute L(0) and s (for each ray traced) using rtrace with some options at all? (I tried to analyze source codes of Radiance programs to find out it, but I’m not a programmer and it’s to complicated to me to understand it)

Try the settings above and see what happens.

Best regards
Marcin Gawronski

Best,
-Greg

Hi Greg!

Thanks for leads. I tried the settings you suggested but problem still occured. I continued my search and I found out what was wrong: the -I parameter! I used -i and I get as earlier table of zeros plus one correct value (8829, this same value I get when I use only -ov). The problem is still with distance. For this zero values sometimes distance l equals 0 (most of rays) and sometimes it's normal value (from more or less 1.0005 to 1.5955). For non-zero value (8829) distance l=0.01).

I also noticed, that when I use -me parameter (the value of -me 0.2 0.2 0.2 is not so large, I mean for test calculations, not for real media) Radiance counts the L(s) value using l=1.156, this is exactly average of distances l for this zero values! This is quite strange to me...

Anyway, this case is solved.

Further contemplations of problem:

I started this discussion, because I want to calculate some formula. First I thought, that it will be possible to compute it using results get from rtrace (value and distance for single ray) but now I know it's much more complicated. In the file with results there are a lot of data that are finally casted away (aren't they?), so I think that operations on this data is not a good idea.

My new concept is to write(change?) a few additional lines to code of "rayparticipate" function. However I don't really understand this code... :frowning:
I can't find where is hide this formula
L(s)=L(0)*exp(-ext*s) (assume albedo=0)
I would like to add to formula above some value according to expression
L1(s)=L(s)+[L(0)-L(s)]*[1-exp(-ext*s)]
I want "rayparticipate" function to return me this L1(s) value instead of L(s). Is this possible? Could you tell me where and what I have to add/change in code of this function? (I attach the code below)
I also thought about write new function similar to "rayparticipate" but it possibly required more changes (not in raytrace.c but also in a few another files).

I will be very thankful for help.
Regards, Marcin

extern void
rayparticipate( /* compute ray medium participation */
     register RAY *r
)
{
     COLOR ce, ca;
     double re, ge, be;

     if (intens(r->cext) <= 1./FHUGE)
         return; /* no medium */
     re = r->rot*colval(r->cext,RED);
     ge = r->rot*colval(r->cext,GRN);
     be = r->rot*colval(r->cext,BLU);
     if (r->crtype & SHADOW) { /* no scattering for sources */
         re *= 1. - colval(r->albedo,RED);
         ge *= 1. - colval(r->albedo,GRN);
         be *= 1. - colval(r->albedo,BLU);
     }
     setcolor(ce, re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
             ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
             be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
     multcolor(r->rcol, ce); /* path extinction */
     if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
         return; /* no scattering */
     setcolor(ca,
      colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
       colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
       colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
     addcolor(r->rcol, ca); /* ambient in scattering */
     srcscatter(r); /* source in scattering */
}

Greg Ward pisze:

···

Hi Marcin,

I will try to answer your questions inline, below...

From: Marcin Gawroński <[email protected]>
Date: March 31, 2008 3:51:46 AM PDT

Dear Group

I use Radiance for a few years, and I handled with different problems so far. Now I have to complicated problem and I need some help. I engage in energy transport in participating media (rtrace with parameter –me).

As I read in ‘Rendering with Radiance’ value of expression
L(s) = L(0)*ext-(kappa*s) (assume albedo omega=0) (1)
is computed ‘after all the ray-surface interactions’ (page 591-592)

Is this formula computed for each ray, and then values connected with all rays are added? (it seems to me it is) Or maybe first values for all rays are added and after expression (1) is computed?

This formula is applied for each ray. You can read the code in src/rt/raytrace.c if that helps. Look at the "rayparticipate" function, which is called from "raytrace".

I need for my algorithm data connected with single ray: the value L(0) and distance s.

Can't you use -otvL with -me 0 0 0 in rtrace? This will report the ray length and value for the entire ray tree.

I tried to use rtrace with some options (all parameters are presented below – file: render_h.opt):
- ‘-otl’ – to get the distance from origin to object (s), but I’m not sure if s = l (l – effective length of ray)
- ‘-otv’ – to get value of each ray traced, but I get a table of zero values (something is wrong, I don’t know what)

Only rays that are linked to tree branches that end in glow surfaces or light sources will have non-zero values if -av 0 0 0 (the default) is specified. I suspect the problem in your case is that -me 0.2 0.2 0.2 is so large that ray paths are never short enough to yield a non-zero result.

Is this possible to compute L(0) and s (for each ray traced) using rtrace with some options at all? (I tried to analyze source codes of Radiance programs to find out it, but I’m not a programmer and it’s to complicated to me to understand it)

Try the settings above and see what happens.

Best regards
Marcin Gawronski

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

----------------------------------------------------------------------
Poprowadz swoj klub do zwyciestwa!
Sprawdz >>> http://link.interia.pl/f1d76

Hello Marcin,

I am struggling a little bit with the language barrier, but I'm going to assume you don't wish to continue the previous discussion, and are instead focused on modifying rayparticipate to model the formula you give below. I won't ask why you want it, but here are the changes to get you there:

extern void
rayparticipate( /* compute ray medium participation */
     register RAY *r
)
{
     COLOR ce, ca;
     double re, ge, be;
     double rv, gv, bv;
    /* modified to return: L(s)+[L(0)-L(s)]*[1-exp(-ext*s)] */
    /* not that this equals: L(0)*exp(-ext*s)+[L(0)-L(0)*exp(-ext*s)]*[1-exp(-ext*s)] */
    /* which reduces to: L(0)*[1 - exp(-ext*s) + exp(-2*ext*s)] */
     if (intens(r->cext) <= 1./FHUGE)
         return; /* no medium */
     re = r->rot*colval(r->cext,RED);
     ge = r->rot*colval(r->cext,GRN);
     be = r->rot*colval(r->cext,BLU);
     if (r->crtype & SHADOW) { /* no scattering for sources */
         re *= 1. - colval(r->albedo,RED);
         ge *= 1. - colval(r->albedo,GRN);
         be *= 1. - colval(r->albedo,BLU);
     }
  rv = 1. - (re<=FTINY ? 1. : re>92. ? 0. : exp(-re)) +
      (re<=FTINY ? 1. : re>46. ? 0. : exp(-2.*re));
  gv = 1. - (ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge)) +
      (ge<=FTINY ? 1. : ge>46. ? 0. : exp(-2.*ge));
  bv = 1. - (be<=FTINY ? 1. : be>92. ? 0. : exp(-be)) +
      (be<=FTINY ? 1. : be>46. ? 0. : exp(-2.*rebe);
     setcolor(ce, rv, gv, bv);
     multcolor(r->rcol, ce); /* path extinction */
     if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
         return; /* no scattering */
     setcolor(ca,
      colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
       colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
       colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
     addcolor(r->rcol, ca); /* ambient in scattering */
     srcscatter(r); /* source in scattering */
}

Hope this is useful.
-Greg

···

From: Marcin Gawroński <[email protected]>
Date: April 24, 2008 4:24:11 AM PDT

Hi Greg!

Thanks for leads. I tried the settings you suggested but problem still occured. I continued my search and I found out what was wrong: the -I parameter! I used -i and I get as earlier table of zeros plus one correct value (8829, this same value I get when I use only -ov). The problem is still with distance. For this zero values sometimes distance l equals 0 (most of rays) and sometimes it's normal value (from more or less 1.0005 to 1.5955). For non-zero value (8829) distance l=0.01).

I also noticed, that when I use -me parameter (the value of -me 0.2 0.2 0.2 is not so large, I mean for test calculations, not for real media) Radiance counts the L(s) value using l=1.156, this is exactly average of distances l for this zero values! This is quite strange to me...

Anyway, this case is solved.

Further contemplations of problem:

I started this discussion, because I want to calculate some formula. First I thought, that it will be possible to compute it using results get from rtrace (value and distance for single ray) but now I know it's much more complicated. In the file with results there are a lot of data that are finally casted away (aren't they?), so I think that operations on this data is not a good idea.

My new concept is to write(change?) a few additional lines to code of "rayparticipate" function. However I don't really understand this code... :frowning:
I can't find where is hide this formula
L(s)=L(0)*exp(-ext*s) (assume albedo=0)
I would like to add to formula above some value according to expression
L1(s)=L(s)+[L(0)-L(s)]*[1-exp(-ext*s)]
I want "rayparticipate" function to return me this L1(s) value instead of L(s). Is this possible? Could you tell me where and what I have to add/change in code of this function? (I attach the code below)
I also thought about write new function similar to "rayparticipate" but it possibly required more changes (not in raytrace.c but also in a few another files).

I will be very thankful for help.
Regards, Marcin

extern void
rayparticipate( /* compute ray medium participation */
    register RAY *r
)
{
    COLOR ce, ca;
    double re, ge, be;

    if (intens(r->cext) <= 1./FHUGE)
        return; /* no medium */
    re = r->rot*colval(r->cext,RED);
    ge = r->rot*colval(r->cext,GRN);
    be = r->rot*colval(r->cext,BLU);
    if (r->crtype & SHADOW) { /* no scattering for sources */
        re *= 1. - colval(r->albedo,RED);
        ge *= 1. - colval(r->albedo,GRN);
        be *= 1. - colval(r->albedo,BLU);
    }
    setcolor(ce, re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
            ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
            be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
    multcolor(r->rcol, ce); /* path extinction */
    if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
        return; /* no scattering */
    setcolor(ca,
     colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
      colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
      colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
    addcolor(r->rcol, ca); /* ambient in scattering */
    srcscatter(r); /* source in scattering */
}

Hi Greg!

Thank you very much for help. Changes in rayparticipate function was useful to me indeed. I had a little problems with compiling, but now everything is ok.
Best regards
Marcin

Greg Ward pisze:

···

Hello Marcin,

I am struggling a little bit with the language barrier, but I'm going to assume you don't wish to continue the previous discussion, and are instead focused on modifying rayparticipate to model the formula you give below. I won't ask why you want it, but here are the changes to get you there:

Hope this is useful.
-Greg

----------------------------------------------------------------------
Wyslij video i wygraj aparat!
Kliknij >>> http://link.interia.pl/f1df4