[Radiance-general] Re: rtrace: -ospec options

Greg Ward gregoryjward at gmail.com
Fri Apr 25 21:08:21 PDT 2008


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 <marcin.gawronski at poczta.fm>
> 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... :(
> 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 */
> }



More information about the Radiance-general mailing list