Revision: 20919
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20919
Author:   yukishiro
Date:     2009-06-16 07:34:24 +0200 (Tue, 16 Jun 2009)

Log Message:
-----------
add preview (the current way of previewing light env is totally a hack...)

Modified Paths:
--------------
    branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c
    
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
    
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c
    branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
    branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c

Modified: 
branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c  
2009-06-16 03:27:57 UTC (rev 20918)
+++ branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c  
2009-06-16 05:34:24 UTC (rev 20919)
@@ -433,7 +433,6 @@
                        sce->world= (World *)id;
                }
                 else if(id_type==ID_LE) {
-                       sce->lay= 1<<MA_LIGHT;
                        sce->lightenv = (LightEnv *)id;
                 }
                

Modified: 
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
===================================================================
--- 
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c   
    2009-06-16 03:27:57 UTC (rev 20918)
+++ 
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c   
    2009-06-16 05:34:24 UTC (rev 20919)
@@ -554,10 +554,8 @@
                                 compute_color(scene, ps);
                                lpaint_exit(C, op);
                                 undo_lightpaint_push(scene);
-                                // signal for recompute
-                                vc->rv3d->rflag |= RV3D_RECALCMCOL;
-                                ED_region_tag_redraw(vc->ar);
 
+                               WM_event_add_notifier(C, NC_LIGHTENV, NULL);
                                return OPERATOR_FINISHED;
                        }
                        /* pass on, first press gets painted too */

Modified: 
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- 
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c  
    2009-06-16 03:27:57 UTC (rev 20918)
+++ 
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c  
    2009-06-16 05:34:24 UTC (rev 20919)
@@ -423,6 +423,11 @@
                         * more context than just the region */
                        ED_region_tag_redraw(ar);
                        break;
+               case NC_LIGHTENV:       
+                        rv3d = ar->regiondata;
+                        rv3d->rflag |= RV3D_RECALCMCOL;
+                       ED_region_tag_redraw(ar);
+                       break;
        }
 }
 

Modified: 
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h    
2009-06-16 03:27:57 UTC (rev 20918)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_material_types.h    
2009-06-16 05:34:24 UTC (rev 20919)
@@ -325,7 +325,6 @@
 #define MA_SKY                 7
 #define MA_HAIR                        10
 #define MA_ATMOS               11
-#define MA_LIGHT                12
 
 /* pr_back */
 #define MA_DARK                        1

Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h       
2009-06-16 03:27:57 UTC (rev 20918)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h       
2009-06-16 05:34:24 UTC (rev 20919)
@@ -135,7 +135,7 @@
 #define SCE_LAY_ZTRA   2
 #define SCE_LAY_HALO   4
 #define SCE_LAY_EDGE   8
-#define SCE_LAY_SKY            16
+#define SCE_LAY_SKY    16
 #define SCE_LAY_STRAND 32
        /* flags between 32 and 0x8000 are set to 1 already, for future options 
*/
 

Modified: 
branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c
===================================================================
--- 
branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c    
    2009-06-16 03:27:57 UTC (rev 20918)
+++ 
branches/soc-2009-yukishiro/source/blender/render/intern/source/rendercore.c    
    2009-06-16 05:34:24 UTC (rev 20919)
@@ -58,6 +58,8 @@
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
+#include "SH_api.h"
+
 /* local include */
 #include "renderpipeline.h"
 #include "render_types.h"
@@ -1159,6 +1161,17 @@
                        if(rl->layflag & SCE_LAY_HALO)
                                halo_tile(pa, rl);
 
+                // XXX: THIS IS TOTALLY A HACK NOW
+                if(G.f & G_LIGHTPAINT) {
+                        float *fcol= rl->rectf; 
+                        int width = R.disprect.xmax - R.disprect.xmin;
+                        int height = R.disprect.ymax - R.disprect.ymin;
+
+                        SH_LightProbePreview(R.scene->lightenv, width, height,
+                                pa->disprect.xmin, pa->disprect.ymin, 
+                                pa->disprect.xmax, pa->disprect.ymax, fcol);
+                }
+
                /* transp layer */
                if(R.flag & R_ZTRA || R.totstrand) {
                        if(rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) {

Modified: branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/SH_api.h      2009-06-16 
03:27:57 UTC (rev 20918)
+++ branches/soc-2009-yukishiro/source/blender/sh/SH_api.h      2009-06-16 
05:34:24 UTC (rev 20919)
@@ -40,6 +40,8 @@
 void SH_ComputeSceneCoefficients(struct Scene *scene, struct View3D *v3d);
 void SH_ComputeLightCoefficients(struct LightEnv *env);
 void SH_ReconstructLightProbe(struct LightEnv *env, struct ImBuf *ibuf);
+void SH_LightProbePreview(struct LightEnv *env, int width, int height,
+                        int xmin, int ymin, int xmax, int ymax, float *col);
 
 void SH_from_disc(int L, float *n, float area, float *shresult);
 float SH_eval(float *sh, float *v);

Modified: branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c      
2009-06-16 03:27:57 UTC (rev 20918)
+++ branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c      
2009-06-16 05:34:24 UTC (rev 20919)
@@ -357,6 +357,52 @@
         }
 }
 
+void SH_LightProbePreview(LightEnv *env, int width, int height,
+                        int xmin, int ymin, int xmax, int ymax, float *col)
+{
+        int m, i, j;
+        float phi, theta, *y_val, *lval;
+        float u, v, r, xdelta, ydelta;
+        int num_sh = (L+1)*(L+1);
+        Vec3 pnt;
+        ShCoeffs Y;
+
+        Y = allocate_ShCoeffs();
+        xdelta = 2.0f / (float)width;
+        ydelta = 2.0f / (float)height;
+
+        for (i = xmin; i < xmax; i++) {
+                for (j = ymin; j < ymax; j++) {
+                        lval = col + (xmax - xmin) * (j - ymin) * 4 + (i - 
xmin) * 4;
+
+                        v = 1 - xdelta * i;
+                        u = ydelta * j - 1;
+                        r = sqrt(u * u + v * v);
+                        if (r > 1.0) continue;
+        
+                        theta = M_PI * r;
+                        phi = atan2(v, u);
+                        pnt[0] = sin(theta) * cos(phi);
+                        pnt[1] = sin(theta) * sin(phi);
+                        pnt[2] = cos(theta);
+        
+                        compute_Y(pnt, Y);
+                        y_val = *Y;
+
+                        lval[0] = lval[1] = lval[2] = 0.0;
+                        for (m = 0; m < num_sh; m++) {
+                                lval[0] += y_val[m] * env->shcoeffs[m][0];
+                                lval[1] += y_val[m] * env->shcoeffs[m][1];
+                                lval[2] += y_val[m] * env->shcoeffs[m][2];
+                        }
+                        lval[3] = 1.0;
+                }
+        }
+        
+        free_ShCoeffs(Y);
+
+}
+
 void SH_ReconstructLightProbe(LightEnv *env, ImBuf *ibuf)
 {       
         int m, i, j;


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

Reply via email to