merge with/from trunk at r35190
[blender.git] / source / blender / gpu / intern / gpu_material.c
index 732cfed47d1194e7a294d5dacf743694c68f1d6d..675c73da960ba3b8c83a036ea4b0e20cf7cbba80 100644 (file)
@@ -104,8 +104,8 @@ struct GPULamp {
 
        int type, mode, lay, hide;
 
-       float dynenergy, dyncol[3];
-       float energy, col[3];
+       float dynpower, dyncol[3];
+       float power, col[3];
 
        float co[3], vec[3];
        float dynco[3], dynvec[3];
@@ -114,7 +114,7 @@ struct GPULamp {
        float dynimat[4][4];
 
        float spotsi, spotbl, k;
-       float dist, att1, att2;
+       float dist;
 
        float bias, d, clipend;
        int size;
@@ -256,11 +256,11 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
                        lamp= nlink->data;
 
                        if(!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) {
-                               lamp->dynenergy = lamp->energy;
+                               lamp->dynpower = lamp->power;
                                VECCOPY(lamp->dyncol, lamp->col);
                        }
                        else {
-                               lamp->dynenergy = 0.0f;
+                               lamp->dynpower = 0.0f;
                                lamp->dyncol[0]= lamp->dyncol[1]= lamp->dyncol[2] = 0.0f;
                        }
                }
@@ -395,9 +395,6 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode
                        case LA_FALLOFF_INVSQUARE:
                                GPU_link(mat, "lamp_falloff_invsquare", GPU_uniform(&lamp->dist), *dist, &visifac);
                                break;
-                       case LA_FALLOFF_SLIDERS:
-                               GPU_link(mat, "lamp_falloff_sliders", GPU_uniform(&lamp->dist), GPU_uniform(&lamp->att1), GPU_uniform(&lamp->att2), *dist, &visifac);
-                               break;
                        case LA_FALLOFF_CURVE:
                                {
                                        float *array;
@@ -524,9 +521,6 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G
                else {
                        /* input */
                        switch(ma->rampin_col) {
-                       case MA_RAMP_IN_ENERGY:
-                               GPU_link(mat, "ramp_rgbtobw", rgb, &fac);
-                               break;
                        case MA_RAMP_IN_SHADER:
                                fac= is;
                                break;
@@ -577,9 +571,6 @@ static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t
                
                /* input */
                switch(ma->rampin_spec) {
-               case MA_RAMP_IN_ENERGY:
-                       fac = t;
-                       break;
                case MA_RAMP_IN_SHADER:
                        fac = is;
                        break;
@@ -679,7 +670,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
                        
                        if(lamp->mode & LA_ONLYSHADOW) {
                                GPU_link(mat, "shade_only_shadow", i, shadfac,
-                                       GPU_dynamic_uniform(&lamp->dynenergy), &shadfac);
+                                       GPU_dynamic_uniform(&lamp->dynpower), &shadfac);
                                
                                if(!(lamp->mode & LA_NO_DIFF))
                                        GPU_link(mat, "shade_only_shadow_diffuse", shadfac, shi->rgb,
@@ -1259,10 +1250,10 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
 void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
 {
        GPUMaterial *mat= shi->gpumat;
-       GPUNodeLink *emit, *ulinfac, *ulogfac, *mistfac;
+       GPUNodeLink *emit, *mistfac;
        Material *ma= shi->mat;
        World *world= mat->scene->world;
-       float linfac, logfac, misttype;
+       float misttype;
 
        memset(shr, 0, sizeof(*shr));
 
@@ -1300,20 +1291,6 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
                shr->alpha = shi->alpha;
 
                if(world) {
-                       /* exposure correction */
-                       if(world->exp!=0.0f || world->range!=1.0f) {
-                               linfac= 1.0 + pow((2.0*world->exp + 0.5), -10);
-                               logfac= log((linfac-1.0)/linfac)/world->range;
-
-                               GPU_link(mat, "set_value", GPU_uniform(&linfac), &ulinfac);
-                               GPU_link(mat, "set_value", GPU_uniform(&logfac), &ulogfac);
-
-                               GPU_link(mat, "shade_exposure_correct", shr->combined,
-                                       ulinfac, ulogfac, &shr->combined);
-                               GPU_link(mat, "shade_exposure_correct", shr->spec,
-                                       ulinfac, ulogfac, &shr->spec);
-                       }
-
                        /* ambient color */
                        if(world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) {
                                if(GPU_link_changed(shi->amb) || ma->amb != 0.0f)
@@ -1442,14 +1419,14 @@ void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[][4])
        invert_m4_m4(lamp->imat, mat);
 }
 
-void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy)
+void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float power)
 {
-       lamp->energy = energy;
-       if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
+       lamp->power = power;
+       if(lamp->mode & LA_NEG) lamp->power= -lamp->power;
 
-       lamp->col[0]= r* lamp->energy;
-       lamp->col[1]= g* lamp->energy;
-       lamp->col[2]= b* lamp->energy;
+       lamp->col[0]= r* lamp->power;
+       lamp->col[1]= g* lamp->power;
+       lamp->col[2]= b* lamp->power;
 }
 
 static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp)
@@ -1465,12 +1442,12 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
        lamp->mode = la->mode;
        lamp->type = la->type;
 
-       lamp->energy = la->energy;
-       if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy;
+       lamp->power= (ELEM(la->type, LA_SUN, LA_HEMI))? la->energy*M_PI: la->energy*M_PI; //XXX la->power;
+       if(lamp->mode & LA_NEG) lamp->power= -lamp->power;
 
-       lamp->col[0]= la->r*lamp->energy;
-       lamp->col[1]= la->g*lamp->energy;
-       lamp->col[2]= la->b*lamp->energy;
+       lamp->col[0]= la->r*lamp->power;
+       lamp->col[1]= la->g*lamp->power;
+       lamp->col[2]= la->b*lamp->power;
 
        GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
 
@@ -1484,8 +1461,6 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
 
        lamp->dist= la->dist;
        lamp->falloff_type= la->falloff_type;
-       lamp->att1= la->att1;
-       lamp->att2= la->att2;
        lamp->curfalloff= la->curfalloff;
 
        /* initshadowbuf */