Revision: 27525
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27525
Author:   blendix
Date:     2010-03-15 23:03:24 +0100 (Mon, 15 Mar 2010)

Log Message:
-----------
Render Branch: don't do shade once trick for strands now, this does not
work well at the moment. Full shading also leads to blurry color textures
at the moment, will have to think of a way around this.

Modified Paths:
--------------
    branches/render25/source/blender/render/intern/include/shading.h
    branches/render25/source/blender/render/intern/source/cache.c
    branches/render25/source/blender/render/intern/source/rayshade.c
    branches/render25/source/blender/render/intern/source/shadeoutput.c

Modified: branches/render25/source/blender/render/intern/include/shading.h
===================================================================
--- branches/render25/source/blender/render/intern/include/shading.h    
2010-03-15 20:38:04 UTC (rev 27524)
+++ branches/render25/source/blender/render/intern/include/shading.h    
2010-03-15 22:03:24 UTC (rev 27525)
@@ -97,6 +97,7 @@
 
 void shade_color(struct Render *re, struct ShadeInput *shi, ShadeResult *shr);
 void shade_jittered_coords(struct Render *re, struct ShadeInput *shi, int max, 
float jitco[RE_MAX_OSA][3], int *totjitco);
+void shade_strand_surface_co(struct ShadeInput *shi, float co[3], float n[3]);
 void shade_surface_direct(struct Render *re, struct ShadeInput *shi, struct 
ShadeResult *shr);
 
 /* Utilities */

Modified: branches/render25/source/blender/render/intern/source/cache.c
===================================================================
--- branches/render25/source/blender/render/intern/source/cache.c       
2010-03-15 20:38:04 UTC (rev 27524)
+++ branches/render25/source/blender/render/intern/source/cache.c       
2010-03-15 22:03:24 UTC (rev 27525)
@@ -762,7 +762,7 @@
        
        /* do raytracing */
 
-       if(method == WO_LIGHT_SHADE_FULL && preprocess) {
+       if(method == WO_LIGHT_SHADE_FULL && preprocess && 
!shi->primitive.strand) {
                /* for full shading, we need material & textures */
                shade_input_init_material(re, shi);
                shade_input_set_shade_texco(re, shi);
@@ -1065,9 +1065,23 @@
                                                float *indirect= 
(re->db.wrld.mode & WO_INDIRECT_LIGHT)? shi->shading.indirect: NULL;
                                                int added;
 
-                                               added= irr_cache_lookup(re, 
shi, cache,
-                                                       ao, env, indirect,
-                                                       geom->co, geom->dxco, 
geom->dyco, geom->vno, geom->vn, 1);
+                                               if(shi->primitive.strand) {
+                                                       added= 0;
+#if 0
+                                                       float co[3], n[3];
+
+                                                       /* TODO: dxco/dyco? */
+                                                       
shade_strand_surface_co(shi, co, n);
+                                                       added= 
irr_cache_lookup(re, shi, cache,
+                                                               ao, env, 
indirect,
+                                                               co, geom->dxco, 
geom->dyco, n, n, 1);
+#endif
+                                               }
+                                               else {
+                                                       added= 
irr_cache_lookup(re, shi, cache,
+                                                               ao, env, 
indirect,
+                                                               geom->co, 
geom->dxco, geom->dyco, geom->vno, geom->vn, 1);
+                                               }
                                                
                                                if(added) {
                                                        if(indirect)

Modified: branches/render25/source/blender/render/intern/source/rayshade.c
===================================================================
--- branches/render25/source/blender/render/intern/source/rayshade.c    
2010-03-15 20:38:04 UTC (rev 27524)
+++ branches/render25/source/blender/render/intern/source/rayshade.c    
2010-03-15 22:03:24 UTC (rev 27525)
@@ -1941,7 +1941,6 @@
                for(a=0; a<3; a++) {
                        normalize_v3_v3(nvec, ldir[a]);
                        negate_v3(nvec); // XXX negated
-
                        mat_bsdf_f(bsdf, &shi->material, &shi->geometry, 
shi->shading.thread, nvec, BSDF_DIFFUSE);
                        
                        dt= dot_v3v3(nvec, shi->geometry.vno);
@@ -2001,6 +2000,9 @@
 {
        int method= re->db.wrld.ao_shading_method;
 
+       if(shi->primitive.strand)
+               method= WO_LIGHT_SHADE_NONE; /* exception for now */
+
        if(ao)
                wo_apply_ao(ao, shi, method, *ao, dir_ao, 1.0f);
        if(env)
@@ -2045,20 +2047,11 @@
        }
        else {
                /* for strands we sample at the root of the strand */
-               StrandRen *strand= shi->primitive.strand;
-               float *surfnor= render_strand_get_surfnor(shi->primitive.obr, 
strand, 0);
-               float offset[3];
-
-               copy_v3_v3(jitco[0], strand->vert[1].co);
+               shade_strand_surface_co(shi, jitco[0], basis[2]);
                totjitco= 1;
-
-               /* offset to avoid self intersection */
-               sub_v3_v3v3(offset, strand->vert[2].co, jitco[0]);
-               normalize_v3(offset);
-               madd_v3_v3fl(jitco[0], offset, 1e-8f);
-
-               copy_v3_v3(basis[2], surfnor);
                ortho_basis_v3v3_v3(basis[0], basis[1], basis[2]);
+
+               method= WO_LIGHT_SHADE_NONE; /* exception for now */
        }
 
        /* clear accumulation variables */

Modified: branches/render25/source/blender/render/intern/source/shadeoutput.c
===================================================================
--- branches/render25/source/blender/render/intern/source/shadeoutput.c 
2010-03-15 20:38:04 UTC (rev 27524)
+++ branches/render25/source/blender/render/intern/source/shadeoutput.c 
2010-03-15 22:03:24 UTC (rev 27525)
@@ -50,6 +50,7 @@
 #include "lamp.h"
 #include "material.h"
 #include "object_mesh.h"
+#include "object_strand.h"
 #include "pixelfilter.h"
 #include "raytrace.h"
 #include "render_types.h"
@@ -120,9 +121,24 @@
                if(re->db.irrcache[thread]) {
                        ShadeGeometry *geom= &shi->geometry;
 
-                       irr_cache_lookup(re, shi, re->db.irrcache[thread],
-                               ao, env, indirect,
-                               geom->co, geom->dxco, geom->dyco, geom->vno, 
geom->vn, 0);
+#if 0
+                       if(shi->primitive.strand) {
+                               float co[3], n[3];
+
+                               /* TODO: dxco/dyco? */
+                               shade_strand_surface_co(shi, co, n);
+
+                               irr_cache_lookup(re, shi, 
re->db.irrcache[thread],
+                                       ao, env, indirect,
+                                       co, geom->dxco, geom->dyco, n, n, 0);
+                       }
+                       else
+#endif
+                       {
+                               irr_cache_lookup(re, shi, 
re->db.irrcache[thread],
+                                       ao, env, indirect,
+                                       geom->co, geom->dxco, geom->dyco, 
geom->vno, geom->vn, 0);
+                       }
                }
                else
                        ray_ao_env_indirect(re, shi, ao, env, indirect, NULL, 
NULL, NULL, NULL, 0);
@@ -380,6 +396,23 @@
        }
 }
 
+void shade_strand_surface_co(ShadeInput *shi, float co[3], float n[3])
+{
+       /* for strands we sample at the root of the strand */
+       StrandRen *strand= shi->primitive.strand;
+       float *surfnor= render_strand_get_surfnor(shi->primitive.obr, strand, 
0);
+       float offset[3];
+
+       copy_v3_v3(co, strand->vert[1].co);
+
+       /* offset to avoid self intersection */
+       sub_v3_v3v3(offset, strand->vert[2].co, co);
+       normalize_v3(offset);
+       madd_v3_v3fl(co, offset, 1e-8f);
+
+       copy_v3_v3(n, surfnor);
+}
+
 static void shade_lamp_accumulate(Render *re, LampRen *lar, ShadeInput *shi, 
ShadeResult *shr, float lv[3], float lainf[3], float lashdw[3], int passflag)
 {
        Material *ma= shi->material.mat;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to