Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_material.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_texture.h" | #include "BKE_texture.h" | ||||
| #include "BKE_group.h" | |||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "GPU_extensions.h" | #include "GPU_extensions.h" | ||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "gpu_codegen.h" | #include "gpu_codegen.h" | ||||
| ▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | for (link=ma->gpumaterial.first; link; link=link->next) { | ||||
| BLI_freelistN(&material->lamps); | BLI_freelistN(&material->lamps); | ||||
| MEM_freeN(material); | MEM_freeN(material); | ||||
| } | } | ||||
| BLI_freelistN(&ma->gpumaterial); | BLI_freelistN(&ma->gpumaterial); | ||||
| } | } | ||||
| bool GPU_lamp_override_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *ma) | |||||
| { | |||||
| if (srl && srl->light_override) | |||||
| return BKE_group_object_exists(srl->light_override, lamp->ob); | |||||
| else if (ma && ma->group) | |||||
| return BKE_group_object_exists(ma->group, lamp->ob); | |||||
| else | |||||
| 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]) | ||||
| { | { | ||||
| if (material->pass) { | if (material->pass) { | ||||
| LinkData *nlink; | LinkData *nlink; | ||||
| GPULamp *lamp; | GPULamp *lamp; | ||||
| GPUShader *shader = GPU_pass_shader(material->pass); | GPUShader *shader = GPU_pass_shader(material->pass); | ||||
| SceneRenderLayer *srl = BLI_findlink(&material->scene->r.layers, material->scene->r.actlay); | |||||
| if (srl) | |||||
| viewlay &= srl->lay; | |||||
| /* handle layer lamps */ | /* handle layer lamps */ | ||||
| for (nlink=material->lamps.first; nlink; nlink=nlink->next) { | for (nlink=material->lamps.first; nlink; nlink=nlink->next) { | ||||
| lamp= nlink->data; | lamp= nlink->data; | ||||
| if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) { | if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) | ||||
| && GPU_lamp_override_visible(lamp, srl, material->ma)) { | |||||
| lamp->dynenergy = lamp->energy; | lamp->dynenergy = lamp->energy; | ||||
| copy_v3_v3(lamp->dyncol, lamp->col); | copy_v3_v3(lamp->dyncol, lamp->col); | ||||
| } | } | ||||
| else { | else { | ||||
| lamp->dynenergy = 0.0f; | lamp->dynenergy = 0.0f; | ||||
| lamp->dyncol[0]= lamp->dyncol[1]= lamp->dyncol[2] = 0.0f; | lamp->dyncol[0]= lamp->dyncol[1]= lamp->dyncol[2] = 0.0f; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,921 Lines • Show Last 20 Lines | |||||