diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-09 12:49:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-09 12:49:27 +0300 |
commit | a5b4b0f21c1ae8c96e4fea9abdcfac2fab1cf300 (patch) | |
tree | 0658d8bdfb8ec03652aa04f82ee8a4d243ec6370 /source/blender/draw/engines/clay/clay_engine.c | |
parent | d68f698cf0321477c0734474150eb4bc43c4e85f (diff) | |
parent | abcda06934aba054de8540b66b13c2bbc5f8f515 (diff) |
Merge branch '28' into custom-manipulatorscustom-manipulators
Diffstat (limited to 'source/blender/draw/engines/clay/clay_engine.c')
-rw-r--r-- | source/blender/draw/engines/clay/clay_engine.c | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c index f39438e660c..937cf7579c6 100644 --- a/source/blender/draw/engines/clay/clay_engine.c +++ b/source/blender/draw/engines/clay/clay_engine.c @@ -40,9 +40,10 @@ #include "UI_interface_icons.h" #include "clay_engine.h" -#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */ #ifdef WITH_CLAY_ENGINE +#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */ + /* Shaders */ #define CLAY_ENGINE "BLENDER_CLAY" @@ -276,19 +277,6 @@ static int matcap_to_index(int matcap) return 0; } -/* Van der Corput sequence */ -/* TODO this is duplicated code from eevee_lightprobes.c */ - /* From http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html */ -static float radical_inverse(int i) { - unsigned int bits = (unsigned int)i; - bits = (bits << 16u) | (bits >> 16u); - bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); - bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); - bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); - bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); - return (float)bits * 2.3283064365386963e-10f; -} - /* Using Hammersley distribution */ static float *create_disk_samples(int num_samples) { @@ -298,7 +286,10 @@ static float *create_disk_samples(int num_samples) for (int i = 0; i < num_samples; i++) { float r = (i + 0.5f) * num_samples_inv; - float phi = radical_inverse(i) * 2.0f * M_PI; + double dphi; + BLI_hammersley_1D(i, &dphi); + + float phi = (float)dphi * 2.0f * M_PI; texels[i][0] = cosf(phi); texels[i][1] = sinf(phi); /* This deliberatly distribute more samples @@ -325,7 +316,7 @@ static struct GPUTexture *create_jitter_texture(int num_samples) jitter[i][2] = bn * num_samples_inv; } - UNUSED_VARS(bsdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx); + UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx); return DRW_texture_create_2D(64, 64, DRW_TEX_RGB_16, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]); } @@ -432,7 +423,7 @@ static void CLAY_engine_init(void *vedata) /* SSAO setup */ { const DRWContextState *draw_ctx = DRW_context_state_get(); - SceneLayer *scene_layer = draw_ctx->sl; + SceneLayer *scene_layer = draw_ctx->scene_layer; IDProperty *props = BKE_scene_layer_engine_evaluated_get( scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY); int ssao_samples = BKE_collection_engine_property_value_get_int(props, "ssao_samples"); @@ -502,8 +493,9 @@ static void CLAY_engine_init(void *vedata) } } -static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *UNUSED(vedata), DRWPass *pass, int *material_id, bool use_flat) +static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id, bool use_flat) { + CLAY_StorageList *stl = vedata->stl; CLAY_SceneLayerData *sldata = CLAY_scene_layer_data_get(); DRWShadingGroup *grp = DRW_shgroup_create(use_flat ? e_data.clay_flat_sh : e_data.clay_sh, pass); @@ -519,16 +511,19 @@ static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *UNUSED(vedata), DRWPass * DRW_shgroup_uniform_texture(grp, "ssao_jitter", sldata->jitter_tx); DRW_shgroup_uniform_block(grp, "samples_block", sldata->sampling_ubo); + DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo); return grp; } -static DRWShadingGroup *CLAY_hair_shgroup_create(DRWPass *pass, int *material_id) +static DRWShadingGroup *CLAY_hair_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id) { + CLAY_StorageList *stl = vedata->stl; DRWShadingGroup *grp = DRW_shgroup_create(e_data.hair_sh, pass); DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array); DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1); + DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo); return grp; } @@ -678,16 +673,12 @@ static DRWShadingGroup *CLAY_object_shgrp_get( if (shgrps[id] == NULL) { shgrps[id] = CLAY_shgroup_create( vedata, use_flat ? psl->clay_pass_flat : psl->clay_pass, &e_data.ubo_mat_idxs[id], use_flat); - /* if it's the first shgrp, pass bind the material UBO */ - if (stl->storage->ubo_current_id == 1) { - DRW_shgroup_uniform_block(shgrps[0], "material_block", stl->mat_ubo); - } } return shgrps[id]; } -static DRWShadingGroup *CLAY_hair_shgrp_get(Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl) +static DRWShadingGroup *CLAY_hair_shgrp_get(CLAY_Data *vedata, Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl) { DRWShadingGroup **hair_shgrps = stl->storage->hair_shgrps; @@ -697,11 +688,7 @@ static DRWShadingGroup *CLAY_hair_shgrp_get(Object *ob, CLAY_StorageList *stl, C int hair_id = hair_mat_in_ubo(stl->storage, &hair_mat_ubo_test); if (hair_shgrps[hair_id] == NULL) { - hair_shgrps[hair_id] = CLAY_hair_shgroup_create(psl->hair_pass, &e_data.ubo_mat_idxs[hair_id]); - /* if it's the first shgrp, pass bind the material UBO */ - if (stl->storage->hair_ubo_current_id == 1) { - DRW_shgroup_uniform_block(hair_shgrps[0], "material_block", stl->hair_mat_ubo); - } + hair_shgrps[hair_id] = CLAY_hair_shgroup_create(vedata, psl->hair_pass, &e_data.ubo_mat_idxs[hair_id]); } return hair_shgrps[hair_id]; @@ -771,7 +758,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); const bool is_active = (ob == draw_ctx->obact); if (is_active) { - if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) { + if (DRW_object_is_mode_shade(ob) == true) { return; } } @@ -828,8 +815,8 @@ static void CLAY_cache_populate(void *vedata, Object *ob) unit_m4(mat); if (draw_as == PART_DRAW_PATH) { - geom = DRW_cache_particles_get_hair(psys); - hair_shgrp = CLAY_hair_shgrp_get(ob, stl, psl); + geom = DRW_cache_particles_get_hair(psys, NULL); + hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl); DRW_shgroup_call_add(hair_shgrp, geom, mat); } } @@ -926,7 +913,8 @@ DrawEngineType draw_engine_clay_type = { &CLAY_cache_populate, &CLAY_cache_finish, NULL, - &CLAY_draw_scene + &CLAY_draw_scene, + NULL, }; RenderEngineType DRW_engine_viewport_clay_type = { |