diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-05-02 16:36:09 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-05-02 17:45:08 +0300 |
commit | a2b05accea6e2879832ae4ac4465ca11d49622c5 (patch) | |
tree | 55f92258fd9e16d4081c480b7f6ece31d3cd9083 /source/blender/draw/intern/draw_cache.c | |
parent | 648de1be52d0d205c657a130f462882c4d54b296 (diff) |
Eevee: Fix vertex color being in srgb space.
Now they are properly converted to Linear space before interpolation.
Since the only way to get vertex color in eevee and cycles is via the
attribute node with the CD_AUTO_FROM_NAME flag, we have to know at binding
time which type of buffer will be connected to this auto input.
We store this information inside the batch cache (together with the according
uniform name) and pass it as uniform to the shader which does conversion if
needed. The same shader can then be reused to draw another mesh with
different auto layers configuration.
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index e84a2378a48..110e986f652 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -523,11 +523,19 @@ Gwn_Batch *DRW_cache_object_surface_get(Object *ob) } Gwn_Batch **DRW_cache_object_surface_material_get( - struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) + struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { + if (auto_layer_names != NULL) { + *auto_layer_names = NULL; + *auto_layer_is_srgb = NULL; + *auto_layer_count = 0; + } + switch (ob->type) { case OB_MESH: - return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len); + return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len, + auto_layer_names, auto_layer_is_srgb, auto_layer_count); case OB_CURVE: return DRW_cache_curve_surface_shaded_get(ob, gpumat_array, gpumat_array_len); case OB_SURF: @@ -2298,12 +2306,14 @@ Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) /* Return list of batches */ Gwn_Batch **DRW_cache_mesh_surface_shaded_get( - Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) + Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; - return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len); + return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len, + auto_layer_names, auto_layer_is_srgb, auto_layer_count); } /* Return list of batches */ |