diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-01-11 22:50:45 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-01-12 02:51:15 +0300 |
commit | 9f6e09bd8c14ca7ae61f6f1a0b71801e06429d8b (patch) | |
tree | a4ea7a8e2240188bac0d0eabe79b5a30e26d1fbc /source/blender/draw/modes | |
parent | 0bd20aa7df2ad7710f92e00d9dc72d826f16762a (diff) |
Drawing API: shgroup_instance and shgroup_instance_alpha clarification
shgroup_instance_alpha was getting a color[4] but would only use the
alpha defined upon creation of the shading group.
This was very limiting since it wouldn't allow for different instances
to have different alpha values.
Patch made with Clément Foucault (he made the code of it, while I fixed
all the parts of the code that were relying on shgroup_instance_alpha.
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 69de0d72fb9..90468658764 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1368,22 +1368,20 @@ static void OBJECT_cache_init(void *vedata) /* Spot shapes */ state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND | DRW_STATE_CULL_FRONT; sgl->spot_shapes = psl->spot_shapes[i] = DRW_pass_create("Spot Shape Pass", state); - float cone_spot_alpha = 0.5f; geom = DRW_cache_lamp_spot_volume_get(); - sgl->lamp_spot_volume = shgroup_instance_alpha(sgl->spot_shapes, geom, cone_spot_alpha); + sgl->lamp_spot_volume = shgroup_instance_alpha(sgl->spot_shapes, geom); geom = DRW_cache_lamp_spot_square_volume_get(); - sgl->lamp_spot_volume_rect = shgroup_instance_alpha(sgl->spot_shapes, geom, cone_spot_alpha); + sgl->lamp_spot_volume_rect = shgroup_instance_alpha(sgl->spot_shapes, geom); - cone_spot_alpha = 0.3f; geom = DRW_cache_lamp_spot_volume_get(); - sgl->lamp_spot_volume_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, cone_spot_alpha); + sgl->lamp_spot_volume_outside = shgroup_instance_alpha(sgl->spot_shapes, geom); DRW_shgroup_state_disable(sgl->lamp_spot_volume_outside, DRW_STATE_CULL_FRONT); DRW_shgroup_state_enable(sgl->lamp_spot_volume_outside, DRW_STATE_CULL_BACK); geom = DRW_cache_lamp_spot_square_volume_get(); - sgl->lamp_spot_volume_rect_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, cone_spot_alpha); + sgl->lamp_spot_volume_rect_outside = shgroup_instance_alpha(sgl->spot_shapes, geom); DRW_shgroup_state_disable(sgl->lamp_spot_volume_rect_outside, DRW_STATE_CULL_FRONT); DRW_shgroup_state_enable(sgl->lamp_spot_volume_rect_outside, DRW_STATE_CULL_BACK); } @@ -1524,8 +1522,8 @@ static void DRW_shgroup_lamp(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLayer else if (la->type == LA_SPOT) { float size[3], sizemat[4][4]; static float one = 1.0f; - float cone_inside[3] = {0.0f, 0.0f, 0.0f}; - float cone_outside[3] = {1.0f, 1.0f, 1.0f}; + float cone_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f}; + float cone_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f}; float blend = 1.0f - pow2f(la->spotblend); size[0] = size[1] = sinf(la->spotsize * 0.5f) * la->dist; size[2] = cosf(la->spotsize * 0.5f) * la->dist; |