Revision: 45767
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45767&view=rev
Author:   kunigami
Date:     2011-08-03 15:24:04 +0000 (Wed, 03 Aug 2011)

Log Message:
-----------
changed the field reflection by ray_type so that it can also represent 
transmission rays. I hope this way the logic gets clearer

Modified Paths:
--------------
    brlcad/trunk/src/liboptical/liboslrend.cpp
    brlcad/trunk/src/liboptical/liboslrend.h
    brlcad/trunk/src/liboptical/sh_osl.cpp

Modified: brlcad/trunk/src/liboptical/liboslrend.cpp
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.cpp  2011-08-02 20:05:14 UTC (rev 
45766)
+++ brlcad/trunk/src/liboptical/liboslrend.cpp  2011-08-03 15:24:04 UTC (rev 
45767)
@@ -165,11 +165,16 @@
            Vec3 omega_in, zero(0.0f);
            Color3 eval;
            float pdf = 0.0;
+           
+           ustring ulabel = bsdf->sample(globals.Ng, globals.I, zero, zero,
+                                         erand48(Xi), erand48(Xi),
+                                         omega_in, zero, zero, pdf, eval);
+           
+           if(ulabel == OSL::Labels::REFLECT)
+               info->out_ray_type |= RAY_REFLECT;
+           else if(ulabel == OSL::Labels::TRANSMIT)
+               info->out_ray_type |= RAY_TRANSMIT;
 
-           bsdf->sample(globals.Ng, globals.I, zero, zero,
-                        erand48(Xi), erand48(Xi),
-                        omega_in, zero, zero, pdf, eval);
-
            if(pdf != 0.0f) {
                OSLRenderer::Vec3toPoint_t(globals.P, info->out_ray.origin);
 

Modified: brlcad/trunk/src/liboptical/liboslrend.h
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.h    2011-08-02 20:05:14 UTC (rev 
45766)
+++ brlcad/trunk/src/liboptical/liboslrend.h    2011-08-03 15:24:04 UTC (rev 
45767)
@@ -47,6 +47,11 @@
     point_t origin;
 } Ray;
 
+enum RayType {
+    RAY_REFLECT = 1,
+    RAY_TRANSMIT = 2
+};
+
 /* Shared struct by which the C shader and the C++ render system may
    exchange information
 */
@@ -70,6 +75,7 @@
     /* -- output -- */
     point_t pc;           /* Color of the point (or multiplier) */
     int doreflection;     /* 1 if there will be reflection 0, otherwise */
+    int out_ray_type;     /* bitflag describing output ray type (bit 0: 
reflection; 1: refraction) */
     Ray out_ray;          /* output ray (in case of reflection) */
 
     /* Experimental! Don't use yet */

Modified: brlcad/trunk/src/liboptical/sh_osl.cpp
===================================================================
--- brlcad/trunk/src/liboptical/sh_osl.cpp      2011-08-02 20:05:14 UTC (rev 
45766)
+++ brlcad/trunk/src/liboptical/sh_osl.cpp      2011-08-03 15:24:04 UTC (rev 
45767)
@@ -691,11 +691,12 @@
 
        /* We only perform reflection if application decides to */
        info.doreflection = 0;
+       info.out_ray_type = 0;
 
        Color3 weight = oslr->QueryColor(&info);
 
        /* Fire another ray */
-       if(info.doreflection == 1){
+       if((info.out_ray_type & RAY_REFLECT) || (info.out_ray_type & 
RAY_TRANSMIT)){
        
            struct application new_ap;
            RT_APPLICATION_INIT(&new_ap);
@@ -710,7 +711,7 @@
            VMOVE(new_ap.a_ray.r_pt, info.out_ray.origin);
        
            /* This next ray represents refraction */
-           if (VDOT(info.N, info.out_ray.dir) < 0.0f){
+           if (info.out_ray_type & RAY_TRANSMIT){
            
                /* Displace the hit point a little bit in the direction
                   of the next ray */


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to