Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-03-28 01:09:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-03-28 01:09:45 +0300
commit6d21970aa06a31398ed4a78b1c596f30a0b9ee87 (patch)
treeafd21bd7a3f0c98020c9207d631e1e96da73dfb0 /source/blender/draw/engines/eevee/eevee_lights.c
parent4d3d10f6251c09006890ebb00f490d4915d47a96 (diff)
Eevee: Diffuse Lights (1 / 2)
I added srgb tonemapping for previewing purpose. Also since the color buffer is still not HDR, there is ugly artifacts (fixed in part2)
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_lights.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index c0359cdd042..c073175a0b2 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -30,9 +30,12 @@
#define MAX_LIGHT 210 /* TODO : find size by dividing UBO max size by light data size */
typedef struct EEVEE_Light {
- float position[3], pad;
+ float position[3], dist;
float color[3], spec;
- float spot_size, spot_blend, area_x, area_y;
+ float spotsize, spotblend, radius, shadowid;
+ float rightvec[3], sizex;
+ float upvec[3], sizey;
+ float forwardvec[3], lamptype;
} EEVEE_Light;
@@ -88,11 +91,44 @@ void EEVEE_lights_update(EEVEE_StorageList *stl)
EEVEE_Light *evli = stl->lights_data + i;
Object *ob = stl->lights_ref[i];
Lamp *la = (Lamp *)ob->data;
+ float mat[4][4], scale[3];
+ /* Position */
copy_v3_v3(evli->position, ob->obmat[3]);
+
+ /* Color */
evli->color[0] = la->r * la->energy;
evli->color[1] = la->g * la->energy;
evli->color[2] = la->b * la->energy;
+
+ /* Influence Radius */
+ evli->dist = la->dist;
+
+ /* Vectors */
+ normalize_m4_m4_ex(mat, ob->obmat, scale);
+ copy_v3_v3(evli->forwardvec, mat[2]);
+ normalize_v3(evli->forwardvec);
+ negate_v3(evli->forwardvec);
+
+ copy_v3_v3(evli->rightvec, mat[0]);
+ normalize_v3(evli->rightvec);
+
+ copy_v3_v3(evli->upvec, mat[1]);
+ normalize_v3(evli->upvec);
+
+ /* Spot size & blend */
+ if (la->type == LA_SPOT) {
+ evli->sizex = scale[0] / scale[2];
+ evli->sizey = scale[1] / scale[2];
+ evli->spotsize = cosf(la->spotsize * 0.5f);
+ evli->spotblend = (1.0f - evli->spotsize) * la->spotblend;
+ }
+ // else if (la->type == LA_SPOT) {
+
+ // }
+
+ /* Lamp Type */
+ evli->lamptype = (float)la->type;
}
/* Upload buffer to GPU */