Followup to rB1973b17fce65, partially bring back GLSL lamp's previous behavior.
authorIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Thu, 29 May 2014 05:53:33 +0000 (14:53 +0900)
committerIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Thu, 29 May 2014 23:22:44 +0000 (08:22 +0900)
Using layer visibility in active render layer makes more accurate
preview but can cause problems in some cases:

https://developer.blender.org/rB1973b17fce65a4dfececb45b19abec37898c1ab5#comment-1

GLSL lamps now ignore layer visibility if lock_camera_and_layers is
OFF or game engine is running. The material lamp group still works
unconditionally though.

source/blender/editors/space_view3d/view3d_draw.c
source/blender/gpu/GPU_material.h
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_material.c
source/gameengine/Ketsji/BL_BlenderShader.cpp

index 219d77a7e58a26779ed4f39f863de45d067e9454..2eef7d9573c18420585a8d82f7511f060cae39bc 100644 (file)
@@ -2416,7 +2416,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
        Scene *sce_iter;
        Base *base;
        Object *ob;
-       SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+       SceneRenderLayer *srl = v3d->scenelock ? BLI_findlink(&scene->r.layers, scene->r.actlay) : NULL;
        
        BLI_listbase_clear(&shadows);
        
index 1011ac809010790245731ba72c84898be1ca2206..a1c249d7f006daa4a33b0a4619205a7d680a5636 100644 (file)
@@ -137,7 +137,7 @@ void GPU_material_free(struct Material *ma);
 void GPU_materials_free(void);
 
 bool GPU_lamp_override_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4]);
+void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], bool scenelock);
 void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float obcol[4], float autobumpscale);
 void GPU_material_unbind(GPUMaterial *material);
 int GPU_material_bound(GPUMaterial *material);
index 1051ce590f4d6e837fea13e5b5409699a1a2a79d..68b8492926b65b3d18e28397b812ddd89d7a7a37 100644 (file)
@@ -1375,6 +1375,7 @@ static struct GPUMaterialState {
        Object *gob;
        Scene *gscene;
        int glay;
+       bool gscenelock;
        float (*gviewmat)[4];
        float (*gviewinv)[4];
 
@@ -1463,6 +1464,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
        GMS.gscene = scene;
        GMS.totmat = use_matcap ? 1 : ob->totcol + 1;  /* materials start from 1, default material is 0 */
        GMS.glay= (v3d->localvd)? v3d->localvd->lay: v3d->lay; /* keep lamps visible in local view */
+       GMS.gscenelock = (v3d->scenelock != 0);
        GMS.gviewmat= rv3d->viewmat;
        GMS.gviewinv= rv3d->viewinv;
 
@@ -1623,7 +1625,7 @@ int GPU_enable_material(int nr, void *attribs)
 
                        gpumat = GPU_material_from_blender(GMS.gscene, mat);
                        GPU_material_vertex_attributes(gpumat, gattribs);
-                       GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT), GMS.gviewmat, GMS.gviewinv);
+                       GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT), GMS.gviewmat, GMS.gviewinv, GMS.gscenelock);
 
                        auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
                        GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gob->col, auto_bump_scale);
index d7fa36a20286ecd4b319f21c55a569a2640cb6e7..5594c0859748ea6a5e62c68ab8d074a8a1630b0a 100644 (file)
@@ -270,13 +270,13 @@ bool GPU_lamp_override_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *m
                return true;
 }
 
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4])
+void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], bool scenelock)
 {
        if (material->pass) {
                LinkData *nlink;
                GPULamp *lamp;
                GPUShader *shader = GPU_pass_shader(material->pass);
-               SceneRenderLayer *srl = BLI_findlink(&material->scene->r.layers, material->scene->r.actlay);
+               SceneRenderLayer *srl = scenelock ? BLI_findlink(&material->scene->r.layers, material->scene->r.actlay) : NULL;
 
                if (srl)
                        viewlay &= srl->lay;
index 6f6925dcf760ffdbd74969bfae75403c962cfc8a..bcdef85bc8a137952a445661c092ee1d1c2f8079 100644 (file)
@@ -77,7 +77,7 @@ void BL_BlenderShader::SetProg(bool enable, double time, RAS_IRasterizer* rasty)
                        view.getValue((float*)viewmat);
                        viewinv.getValue((float*)viewinvmat);
 
-                       GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1, viewmat, viewinvmat);
+                       GPU_material_bind(mGPUMat, mLightLayer, mBlenderScene->lay, time, 1, viewmat, viewinvmat, false);
                }
                else
                        GPU_material_unbind(mGPUMat);