merge with trunk at r31523
[blender.git] / source / blender / gpu / intern / gpu_material.c
index 44ff8d12dfff6c81d11a1439a0a92846a1a35fa4..a86852d6c190ccb4e5d8a4e7993155cdb1f36915 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
-#include "DNA_image_types.h"
 #include "DNA_lamp_types.h"
-#include "DNA_listBase.h"
 #include "DNA_material_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_view3d_types.h"
 #include "DNA_world_types.h"
 
 #include "BKE_anim.h"
@@ -103,7 +99,7 @@ struct GPULamp {
        Object *par;
        Lamp *la;
 
-       int type, mode, lay;
+       int type, mode, lay, hide;
 
        float dynpower, dyncol[3];
        float power, col[3];
@@ -256,7 +252,7 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
                for(nlink=material->lamps.first; nlink; nlink=nlink->next) {
                        lamp= nlink->data;
 
-                       if((lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) {
+                       if(!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) {
                                lamp->dynpower = lamp->power;
                                VECCOPY(lamp->dyncol, lamp->col);
                        }
@@ -995,6 +991,10 @@ static void do_material_tex(GPUShadeInput *shi)
                                        else
                                                GPU_link(mat, "set_value_one", &tin);
                                }
+
+                               if(tex->type==TEX_IMAGE)
+                                       if(mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+                                               GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol);
                                
                                if(mtex->mapto & MAP_COL) {
                                        GPUNodeLink *colfac;
@@ -1221,6 +1221,9 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
                mat->obcolalpha = 1;
                GPU_link(mat, "shade_alpha_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined);
        }
+
+       if(mat->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+               GPU_link(mat, "linearrgb_to_srgb", shr->combined, &shr->combined);
 }
 
 GPUNodeLink *GPU_blender_material(GPUMaterial *mat, Material *ma)
@@ -1287,11 +1290,12 @@ void GPU_materials_free()
 
 /* Lamps and shadow buffers */
 
-void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4])
+void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[][4])
 {
        float mat[4][4];
 
        lamp->lay = lay;
+       lamp->hide = hide;
 
        copy_m4_m4(mat, obmat);
        normalize_m4(mat);
@@ -1332,7 +1336,7 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
        lamp->col[1]= la->g*lamp->power;
        lamp->col[2]= la->b*lamp->power;
 
-       GPU_lamp_update(lamp, ob->lay, ob->obmat);
+       GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat);
 
        lamp->spotsi= la->spotsize;
        if(lamp->mode & LA_HALO)