Compare commits
23 Commits
main
...
temp-gpenc
Author | SHA1 | Date | |
---|---|---|---|
c2fbe46b0f | |||
386ba09498 | |||
6129e20cec | |||
03bbd5f9de | |||
2204bfcf9e | |||
f64db794ee | |||
8e08ffd399 | |||
51be5a7b53 | |||
c5722f4c43 | |||
930d0364b8 | |||
a8bd4e2d59 | |||
879d8e4c2b | |||
b66a221835 | |||
15938e7524 | |||
b57ec68fcf | |||
d0f22a41b0 | |||
4dc62c24e1 | |||
001b97af41 | |||
a3428e07c8 | |||
89415e083d | |||
b3c2926bc0 | |||
7c948609db | |||
ad8b8c07bf |
@@ -351,6 +351,7 @@ data_to_c_simple(engines/gpencil/shaders/gpencil_stroke_frag.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_simple_mix_frag.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_blend_frag.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_merge_depth_frag.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_point_vert.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_point_geom.glsl SRC)
|
||||
data_to_c_simple(engines/gpencil/shaders/gpencil_point_frag.glsl SRC)
|
||||
|
@@ -62,6 +62,7 @@ extern char datatoc_gpencil_edit_point_vert_glsl[];
|
||||
extern char datatoc_gpencil_edit_point_geom_glsl[];
|
||||
extern char datatoc_gpencil_edit_point_frag_glsl[];
|
||||
extern char datatoc_gpencil_blend_frag_glsl[];
|
||||
extern char datatoc_gpencil_merge_depth_frag_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
|
||||
|
||||
@@ -124,35 +125,35 @@ static void GPENCIL_create_framebuffers(void *vedata)
|
||||
/* Framebufers for basic object drawing */
|
||||
if (stl->storage->framebuffer_flag & GP_FRAMEBUFFER_BASIC) {
|
||||
/* temp textures for ping-pong buffers */
|
||||
stl->g_data->temp_depth_tx_a = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_a_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH24_STENCIL8, &draw_engine_gpencil_type);
|
||||
stl->g_data->temp_color_tx_a = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_a_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_a,
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_a_fb,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_a),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_a),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_a_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_a_tx),
|
||||
});
|
||||
|
||||
stl->g_data->temp_depth_tx_b = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_b_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH24_STENCIL8, &draw_engine_gpencil_type);
|
||||
stl->g_data->temp_color_tx_b = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_b_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_b,
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_b_fb,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_b),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_b),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_b_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_b_tx),
|
||||
});
|
||||
|
||||
/* used for FX effects and Layer blending */
|
||||
stl->g_data->temp_depth_tx_fx = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_fx_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH24_STENCIL8, &draw_engine_gpencil_type);
|
||||
stl->g_data->temp_color_tx_fx = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_fx_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_fx,
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fx_fb,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_fx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_fx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_fx_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_fx_tx),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,6 +259,9 @@ static void GPENCIL_create_shaders(void)
|
||||
if (!e_data.gpencil_blend_fullscreen_sh) {
|
||||
e_data.gpencil_blend_fullscreen_sh = DRW_shader_create_fullscreen(
|
||||
datatoc_gpencil_blend_frag_glsl, NULL);
|
||||
|
||||
e_data.gpencil_merge_depth_sh = DRW_shader_create_fullscreen(
|
||||
datatoc_gpencil_merge_depth_frag_glsl, NULL);
|
||||
}
|
||||
|
||||
/* shaders for use when drawing */
|
||||
@@ -298,6 +302,7 @@ static void GPENCIL_engine_free(void)
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_fullscreen_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_simple_fullscreen_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_blend_fullscreen_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_merge_depth_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_background_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_paper_sh);
|
||||
|
||||
@@ -524,10 +529,11 @@ void GPENCIL_cache_init(void *vedata)
|
||||
|
||||
/* full screen pass to combine the result with default framebuffer */
|
||||
struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
|
||||
psl->mix_pass = DRW_pass_create("GPencil Mix Pass",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_pass);
|
||||
psl->mix_screen_pass = DRW_pass_create("GPencil Mix Pass",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.gpencil_fullscreen_sh,
|
||||
psl->mix_screen_pass);
|
||||
DRW_shgroup_call(mix_shgrp, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeColor", &stl->g_data->input_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeDepth", &stl->g_data->input_depth_tx);
|
||||
@@ -541,11 +547,11 @@ void GPENCIL_cache_init(void *vedata)
|
||||
* This pass is used too to take the snapshot used for background_pass. This image
|
||||
* will be used as the background while the user is drawing.
|
||||
*/
|
||||
psl->mix_pass_noblend = DRW_pass_create("GPencil Mix Pass no blend",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS);
|
||||
psl->mix_screen_noblend_pass = DRW_pass_create("GPencil Mix Pass no blend",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS);
|
||||
DRWShadingGroup *mix_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh,
|
||||
psl->mix_pass_noblend);
|
||||
psl->mix_screen_noblend_pass);
|
||||
DRW_shgroup_call(mix_shgrp_noblend, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(
|
||||
mix_shgrp_noblend, "strokeColor", &stl->g_data->input_color_tx);
|
||||
@@ -624,19 +630,20 @@ void GPENCIL_cache_init(void *vedata)
|
||||
}
|
||||
|
||||
/* blend layers pass */
|
||||
psl->blend_pass = DRW_pass_create("GPencil Blend Layers Pass",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
psl->blend_layers_pass = DRW_pass_create("GPencil Blend Layers Pass",
|
||||
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM);
|
||||
DRWShadingGroup *blend_shgrp = DRW_shgroup_create(e_data.gpencil_blend_fullscreen_sh,
|
||||
psl->blend_pass);
|
||||
DRW_shgroup_call(blend_shgrp, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
psl->blend_layers_pass);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_int(blend_shgrp, "mode", &stl->storage->blend_mode, 1);
|
||||
DRW_shgroup_uniform_int(blend_shgrp, "mask_layer", &stl->storage->mask_layer, 1);
|
||||
DRW_shgroup_uniform_int(mix_shgrp, "tonemapping", &stl->storage->tonemapping, 1);
|
||||
DRW_shgroup_call(blend_shgrp, quad, NULL);
|
||||
|
||||
psl->blend_layers_depth_pass = DRW_pass_create("GPencil Merge Depth Pass",
|
||||
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.gpencil_merge_depth_sh,
|
||||
psl->blend_layers_depth_pass);
|
||||
DRW_shgroup_uniform_texture_ref(shgrp, "strokeDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
DRW_shgroup_call(shgrp, quad, NULL);
|
||||
|
||||
/* create effects passes */
|
||||
if (!stl->storage->simplify_fx) {
|
||||
@@ -652,6 +659,7 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
|
||||
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const View3D *v3d = draw_ctx->v3d;
|
||||
tGPencilObjectCache_shgrp *array_elm = NULL;
|
||||
|
||||
int i = stl->g_data->gp_cache_used - 1;
|
||||
tGPencilObjectCache *cache_ob = &stl->g_data->gp_object_cache[i];
|
||||
@@ -666,6 +674,16 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify if the object has layer blending */
|
||||
cache_ob->has_layer_blend = false;
|
||||
for (int e = 0; e < cache_ob->tot_layers; e++) {
|
||||
array_elm = &cache_ob->shgrp_array[e];
|
||||
if ((array_elm->mode != eGplBlendMode_Regular) || (array_elm->mask_layer)) {
|
||||
cache_ob->has_layer_blend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* FX passses */
|
||||
cache_ob->has_fx = false;
|
||||
if ((!stl->storage->simplify_fx) &&
|
||||
@@ -870,16 +888,13 @@ void DRW_gpencil_free_runtime_data(void *ved)
|
||||
MEM_SAFE_FREE(stl->g_data->gp_object_cache);
|
||||
}
|
||||
|
||||
static void gpencil_draw_pass_range(GPENCIL_FramebufferList *fbl,
|
||||
GPENCIL_StorageList *stl,
|
||||
static void gpencil_draw_pass_range(GPENCIL_StorageList *stl,
|
||||
GPENCIL_PassList *psl,
|
||||
GPENCIL_TextureList *txl,
|
||||
GPUFrameBuffer *fb,
|
||||
Object *ob,
|
||||
bGPdata *gpd,
|
||||
DRWShadingGroup *init_shgrp,
|
||||
DRWShadingGroup *end_shgrp,
|
||||
bool multi)
|
||||
DRWShadingGroup *end_shgrp)
|
||||
{
|
||||
if (init_shgrp == NULL) {
|
||||
return;
|
||||
@@ -1020,73 +1035,75 @@ void GPENCIL_draw_scene(void *ved)
|
||||
sizeof(tGPencilObjectCache),
|
||||
gpencil_object_cache_compare_zdepth);
|
||||
|
||||
GPUFrameBuffer *blend_fb = fbl->temp_fx_fb;
|
||||
const bool do_antialiasing = ((!stl->storage->is_mat_preview) &&
|
||||
(stl->storage->multisamples > 0));
|
||||
GPUFrameBuffer *final_fb = (do_antialiasing) ? fbl->multisample_fb : fbl->temp_a_fb;
|
||||
|
||||
for (int i = 0; i < stl->g_data->gp_cache_used; i++) {
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->temp_a_fb, clearcol, 1.0f, 0x0);
|
||||
|
||||
cache_ob = &stl->g_data->gp_object_cache[i];
|
||||
Object *ob = cache_ob->ob;
|
||||
/* TODO: To check if the object has Blend, verify the value of
|
||||
* cache_ob->has_layer_blend
|
||||
* Actually this variable is set to true if any layer has any blend mode
|
||||
* different of Regular mode or the layer has the Masking enabled.
|
||||
*/
|
||||
|
||||
/* TODO: To check if the object has VFX, verify the value of
|
||||
* cache_ob->has_fx
|
||||
*/
|
||||
|
||||
bGPdata *gpd = cache_ob->gpd;
|
||||
init_shgrp = NULL;
|
||||
/* Render stroke in separated framebuffer */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->temp_fb_a, clearcol, 1.0f, 0x0);
|
||||
/* Stroke Pass:
|
||||
* draw only a subset that usually starts with a fill and ends with stroke
|
||||
*/
|
||||
bool use_blend = false;
|
||||
if (cache_ob->tot_layers > 0) {
|
||||
for (int e = 0; e < cache_ob->tot_layers; e++) {
|
||||
bool is_last = (e == cache_ob->tot_layers - 1) ? true : false;
|
||||
array_elm = &cache_ob->shgrp_array[e];
|
||||
init_shgrp = array_elm->init_shgrp;
|
||||
end_shgrp = array_elm->end_shgrp;
|
||||
|
||||
if (((array_elm->mode == eGplBlendMode_Regular) && (!use_blend) &&
|
||||
(!array_elm->mask_layer)) ||
|
||||
(e == 0)) {
|
||||
if (init_shgrp == NULL) {
|
||||
init_shgrp = array_elm->init_shgrp;
|
||||
}
|
||||
end_shgrp = array_elm->end_shgrp;
|
||||
if (stl->storage->multisamples > 0) {
|
||||
GPU_framebuffer_bind(fbl->multisample_fb);
|
||||
}
|
||||
else {
|
||||
use_blend = true;
|
||||
/* draw pending groups */
|
||||
gpencil_draw_pass_range(
|
||||
fbl, stl, psl, txl, fbl->temp_fb_a, ob, gpd, init_shgrp, end_shgrp, is_last);
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
}
|
||||
|
||||
/* Draw current group in separated texture to blend later */
|
||||
init_shgrp = array_elm->init_shgrp;
|
||||
end_shgrp = array_elm->end_shgrp;
|
||||
if (array_elm->mode == eGplBlendMode_Regular) {
|
||||
/* Draw current group in MSAA texture or final texture. */
|
||||
gpencil_draw_pass_range(stl, psl, final_fb, ob, gpd, init_shgrp, end_shgrp);
|
||||
}
|
||||
else {
|
||||
/* Draw current group in separated texture to blend later. */
|
||||
GPU_framebuffer_bind(blend_fb);
|
||||
GPU_framebuffer_clear_color_depth_stencil(blend_fb, clearcol, 1.0f, 0x0);
|
||||
gpencil_draw_pass_range(stl, psl, fbl->temp_fx_fb, ob, gpd, init_shgrp, end_shgrp);
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_fx);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->temp_fb_fx, clearcol, 1.0f, 0x0);
|
||||
gpencil_draw_pass_range(
|
||||
fbl, stl, psl, txl, fbl->temp_fb_fx, ob, gpd, init_shgrp, end_shgrp, is_last);
|
||||
|
||||
/* Blend A texture and FX texture */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->temp_fb_b, clearcol, 1.0f, 0x0);
|
||||
/* Draw Blended texture over MSAA texture */
|
||||
GPU_framebuffer_bind(final_fb);
|
||||
stl->storage->blend_mode = array_elm->mode;
|
||||
stl->storage->mask_layer = (int)array_elm->mask_layer;
|
||||
stl->storage->tonemapping = DRW_state_do_color_management() ? 0 : 1;
|
||||
DRW_draw_pass(psl->blend_pass);
|
||||
stl->storage->tonemapping = 0;
|
||||
|
||||
/* Copy B texture to A texture to follow loop */
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->temp_fb_a, clearcol, 1.0f, 0x0);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
|
||||
/* prepare next group */
|
||||
init_shgrp = NULL;
|
||||
DRW_draw_pass(psl->blend_layers_pass);
|
||||
DRW_draw_pass(psl->blend_layers_depth_pass);
|
||||
}
|
||||
}
|
||||
/* last group */
|
||||
gpencil_draw_pass_range(
|
||||
fbl, stl, psl, txl, fbl->temp_fb_a, ob, gpd, init_shgrp, end_shgrp, true);
|
||||
|
||||
/* Resolve MSAA texture to A texture to follow with VFX */
|
||||
MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, fbl->temp_a_fb, txl);
|
||||
}
|
||||
|
||||
/* Clear multisample framebuffer to avoid garbage in the screen */
|
||||
if (stl->storage->multisamples > 0) {
|
||||
GPU_framebuffer_bind(fbl->multisample_fb);
|
||||
GPU_framebuffer_clear_color_depth_stencil(
|
||||
fbl->multisample_fb, (const float[4]){0.0f}, 1.0f, 0x0);
|
||||
}
|
||||
|
||||
/* Current buffer drawing */
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
if ((!is_render) && (cache_ob->is_dup_ob == false)) {
|
||||
DRW_draw_pass(psl->drawing_pass);
|
||||
}
|
||||
@@ -1096,15 +1113,15 @@ void GPENCIL_draw_scene(void *ved)
|
||||
gpencil_fx_draw(&e_data, vedata, cache_ob);
|
||||
}
|
||||
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_a;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_a;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_a_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_a_tx;
|
||||
|
||||
/* Combine with scene buffer */
|
||||
if ((!is_render) || (fbl->main == NULL)) {
|
||||
if ((!is_render) || (fbl->main_fb == NULL)) {
|
||||
GPU_framebuffer_bind(dfbl->default_fb);
|
||||
}
|
||||
else {
|
||||
GPU_framebuffer_bind(fbl->main);
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
}
|
||||
/* tonemapping */
|
||||
stl->storage->tonemapping = DRW_state_do_color_management() ? 0 : 1;
|
||||
@@ -1125,7 +1142,7 @@ void GPENCIL_draw_scene(void *ved)
|
||||
}
|
||||
|
||||
/* draw mix pass */
|
||||
DRW_draw_pass(psl->mix_pass);
|
||||
DRW_draw_pass(psl->mix_screen_pass);
|
||||
|
||||
/* disable select flag */
|
||||
stl->storage->do_select_outline = 0;
|
||||
@@ -1133,7 +1150,7 @@ void GPENCIL_draw_scene(void *ved)
|
||||
/* prepare for fast drawing */
|
||||
if (!is_render) {
|
||||
if (!playing) {
|
||||
gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass_noblend, clearcol);
|
||||
gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_screen_noblend_pass, clearcol);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -69,6 +69,8 @@ typedef struct tGPencilObjectCache {
|
||||
int idx; /*original index, can change after sort */
|
||||
char *name;
|
||||
|
||||
bool has_layer_blend;
|
||||
|
||||
/* effects */
|
||||
bool has_fx;
|
||||
ListBase shader_fx;
|
||||
@@ -199,12 +201,13 @@ typedef struct GPENCIL_PassList {
|
||||
struct DRWPass *stroke_pass_3d;
|
||||
struct DRWPass *edit_pass;
|
||||
struct DRWPass *drawing_pass;
|
||||
struct DRWPass *mix_pass;
|
||||
struct DRWPass *mix_pass_noblend;
|
||||
struct DRWPass *mix_screen_pass;
|
||||
struct DRWPass *mix_screen_noblend_pass;
|
||||
struct DRWPass *background_pass;
|
||||
struct DRWPass *paper_pass;
|
||||
struct DRWPass *grid_pass;
|
||||
struct DRWPass *blend_pass;
|
||||
struct DRWPass *blend_layers_pass;
|
||||
struct DRWPass *blend_layers_depth_pass;
|
||||
|
||||
/* effects */
|
||||
struct DRWPass *fx_shader_pass;
|
||||
@@ -213,10 +216,10 @@ typedef struct GPENCIL_PassList {
|
||||
} GPENCIL_PassList;
|
||||
|
||||
typedef struct GPENCIL_FramebufferList {
|
||||
struct GPUFrameBuffer *main;
|
||||
struct GPUFrameBuffer *temp_fb_a;
|
||||
struct GPUFrameBuffer *temp_fb_b;
|
||||
struct GPUFrameBuffer *temp_fb_fx;
|
||||
struct GPUFrameBuffer *main_fb;
|
||||
struct GPUFrameBuffer *temp_a_fb;
|
||||
struct GPUFrameBuffer *temp_b_fb;
|
||||
struct GPUFrameBuffer *temp_fx_fb;
|
||||
struct GPUFrameBuffer *background_fb;
|
||||
|
||||
struct GPUFrameBuffer *multisample_fb;
|
||||
@@ -273,14 +276,14 @@ typedef struct g_data {
|
||||
struct GPUTexture *input_color_tx;
|
||||
|
||||
/* working textures */
|
||||
struct GPUTexture *temp_color_tx_a;
|
||||
struct GPUTexture *temp_depth_tx_a;
|
||||
struct GPUTexture *temp_color_a_tx;
|
||||
struct GPUTexture *temp_depth_a_tx;
|
||||
|
||||
struct GPUTexture *temp_color_tx_b;
|
||||
struct GPUTexture *temp_depth_tx_b;
|
||||
struct GPUTexture *temp_color_b_tx;
|
||||
struct GPUTexture *temp_depth_b_tx;
|
||||
|
||||
struct GPUTexture *temp_color_tx_fx;
|
||||
struct GPUTexture *temp_depth_tx_fx;
|
||||
struct GPUTexture *temp_color_fx_tx;
|
||||
struct GPUTexture *temp_depth_fx_tx;
|
||||
|
||||
int session_flag;
|
||||
bool do_instances;
|
||||
@@ -310,6 +313,7 @@ typedef struct GPENCIL_e_data {
|
||||
struct GPUShader *gpencil_fullscreen_sh;
|
||||
struct GPUShader *gpencil_simple_fullscreen_sh;
|
||||
struct GPUShader *gpencil_blend_fullscreen_sh;
|
||||
struct GPUShader *gpencil_merge_depth_sh;
|
||||
struct GPUShader *gpencil_background_sh;
|
||||
struct GPUShader *gpencil_paper_sh;
|
||||
|
||||
|
@@ -84,7 +84,7 @@ void GPENCIL_render_init(GPENCIL_Data *ved, RenderEngine *engine, struct Depsgra
|
||||
size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
|
||||
vedata->render_color_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_RGBA32F, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->main,
|
||||
GPU_framebuffer_ensure_config(&fbl->main_fb,
|
||||
{GPU_ATTACHMENT_TEXTURE(vedata->render_depth_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(vedata->render_color_tx)});
|
||||
|
||||
@@ -198,7 +198,7 @@ static void GPENCIL_render_result_z(struct RenderLayer *rl,
|
||||
if ((view_layer->passflag & SCE_PASS_Z) != 0) {
|
||||
RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_Z, viewname);
|
||||
|
||||
GPU_framebuffer_read_depth(vedata->fbl->main,
|
||||
GPU_framebuffer_read_depth(vedata->fbl->main_fb,
|
||||
rect->xmin,
|
||||
rect->ymin,
|
||||
BLI_rcti_size_x(rect),
|
||||
@@ -240,8 +240,8 @@ static void GPENCIL_render_result_combined(struct RenderLayer *rl,
|
||||
RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_COMBINED, viewname);
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
GPU_framebuffer_bind(fbl->main);
|
||||
GPU_framebuffer_read_color(vedata->fbl->main,
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
GPU_framebuffer_read_color(vedata->fbl->main_fb,
|
||||
rect->xmin,
|
||||
rect->ymin,
|
||||
BLI_rcti_size_x(rect),
|
||||
@@ -295,13 +295,13 @@ void GPENCIL_render_to_image(void *vedata,
|
||||
stl->storage->camera = camera; /* save current camera */
|
||||
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
if (fbl->main) {
|
||||
GPU_framebuffer_texture_attach(fbl->main, ((GPENCIL_Data *)vedata)->render_depth_tx, 0, 0);
|
||||
GPU_framebuffer_texture_attach(fbl->main, ((GPENCIL_Data *)vedata)->render_color_tx, 0, 0);
|
||||
if (fbl->main_fb) {
|
||||
GPU_framebuffer_texture_attach(fbl->main_fb, ((GPENCIL_Data *)vedata)->render_depth_tx, 0, 0);
|
||||
GPU_framebuffer_texture_attach(fbl->main_fb, ((GPENCIL_Data *)vedata)->render_color_tx, 0, 0);
|
||||
/* clean first time the buffer */
|
||||
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
GPU_framebuffer_bind(fbl->main);
|
||||
GPU_framebuffer_clear_color_depth(fbl->main, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->main_fb, clearcol, 1.0f);
|
||||
}
|
||||
|
||||
/* loop all objects and draw */
|
||||
@@ -319,9 +319,9 @@ void GPENCIL_render_to_image(void *vedata,
|
||||
GPENCIL_render_result_z(render_layer, viewname, vedata, rect);
|
||||
|
||||
/* detach textures */
|
||||
if (fbl->main) {
|
||||
GPU_framebuffer_texture_detach(fbl->main, ((GPENCIL_Data *)vedata)->render_depth_tx);
|
||||
GPU_framebuffer_texture_detach(fbl->main, ((GPENCIL_Data *)vedata)->render_color_tx);
|
||||
if (fbl->main_fb) {
|
||||
GPU_framebuffer_texture_detach(fbl->main_fb, ((GPENCIL_Data *)vedata)->render_depth_tx);
|
||||
GPU_framebuffer_texture_detach(fbl->main_fb, ((GPENCIL_Data *)vedata)->render_color_tx);
|
||||
}
|
||||
|
||||
/* merge previous render image with new GP image */
|
||||
|
@@ -202,8 +202,8 @@ static void gpencil_fx_blur(ShaderFxData *fx,
|
||||
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -228,8 +228,8 @@ static void gpencil_fx_colorize(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCI
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_colorize_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "low_color", &fxd->low_color[0], 1);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "high_color", &fxd->high_color[0], 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "mode", &fxd->mode, 1);
|
||||
@@ -261,8 +261,8 @@ static void gpencil_fx_flip(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCIL_Da
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_flip_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "flipmode", &fxd->flipmode, 1);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "wsize", DRW_viewport_size_get(), 1);
|
||||
@@ -291,8 +291,8 @@ static void gpencil_fx_light(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_light_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
@@ -346,8 +346,8 @@ static void gpencil_fx_pixel(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_pixel_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "size", &fxd->size[0], 3);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "color", &fxd->rgba[0], 1);
|
||||
|
||||
@@ -380,8 +380,8 @@ static void gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_rim_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "offset", &fxd->offset[0], 2);
|
||||
@@ -397,8 +397,8 @@ static void gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -411,9 +411,9 @@ static void gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_rim_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeRim", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeRim", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "mask_color", &fxd->mask_rgb[0], 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "mode", &fxd->mode, 1);
|
||||
|
||||
@@ -447,8 +447,8 @@ static void gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_shadow_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "offset", &fxd->offset[0], 2);
|
||||
@@ -481,8 +481,8 @@ static void gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -495,10 +495,10 @@ static void gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_shadow_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
|
||||
fxd->runtime.fx_sh_c = fx_shgrp;
|
||||
}
|
||||
@@ -524,8 +524,8 @@ static void gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_glow_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "glow_color", &fxd->glow_color[0], 1);
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "select_color", &fxd->select_color[0], 1);
|
||||
@@ -537,8 +537,8 @@ static void gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -551,10 +551,10 @@ static void gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_glow_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowColor", &stl->g_data->temp_color_fx_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowDepth", &stl->g_data->temp_depth_fx_tx);
|
||||
|
||||
/* reuse field */
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "alpha_mode", &fxd->blur[1], 1);
|
||||
@@ -586,8 +586,8 @@ static void gpencil_fx_swirl(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_swirl_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
@@ -618,8 +618,8 @@ static void gpencil_fx_wave(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCIL_Da
|
||||
|
||||
DRWShadingGroup *fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_wave_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_a_tx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_a_tx);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "amplitude", &fxd->amplitude, 1);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "period", &fxd->period, 1);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "phase", &fxd->phase, 1);
|
||||
@@ -781,8 +781,8 @@ static void gpencil_draw_fx_pass(GPENCIL_Data *vedata, DRWShadingGroup *shgrp, b
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
const float clearcol[4] = {0.0f};
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_b_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_b_fb, clearcol, 1.0f);
|
||||
|
||||
/* draw effect pass in temp texture (B) using as source the previous image
|
||||
* existing in the other temp texture (A) */
|
||||
@@ -794,12 +794,12 @@ static void gpencil_draw_fx_pass(GPENCIL_Data *vedata, DRWShadingGroup *shgrp, b
|
||||
}
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_b_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_b_tx;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_a_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_screen_noblend_pass);
|
||||
}
|
||||
|
||||
/* helper to manage gaussian blur passes */
|
||||
@@ -845,14 +845,14 @@ static void draw_gpencil_midpass_blur(GPENCIL_Data *vedata, ShaderFxData_Runtime
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
const float clearcol[4] = {0.0f};
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_b_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_b_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, runtime->fx_sh_b, runtime->fx_sh_b);
|
||||
|
||||
/* copy pass from b for ping-pong frame buffers */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_fx);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
GPU_framebuffer_bind(fbl->temp_fx_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fx_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_screen_noblend_pass);
|
||||
}
|
||||
|
||||
/* do blur of mid passes */
|
||||
@@ -861,8 +861,8 @@ static void draw_gpencil_do_blur(
|
||||
{
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_b_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_b_tx;
|
||||
|
||||
if ((samples > 0) && ((bx > 0) || (by > 0))) {
|
||||
for (int x = 0; x < samples; x++) {
|
||||
@@ -897,8 +897,8 @@ static void draw_gpencil_rim_passes(GPENCIL_Data *vedata, RimShaderFxData *fxd)
|
||||
const float clearcol[4] = {0.0f};
|
||||
|
||||
/* prepare mask */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_fx);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_fx_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fx_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh, fxd->runtime.fx_sh);
|
||||
|
||||
/* blur rim */
|
||||
@@ -906,17 +906,17 @@ static void draw_gpencil_rim_passes(GPENCIL_Data *vedata, RimShaderFxData *fxd)
|
||||
vedata, &fxd->runtime, fxd->samples, fxd->blur[0], fxd->blur[1], &fxd->blur[0]);
|
||||
|
||||
/* resolve */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_b_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_b_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_b_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_b_tx;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_a_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_screen_noblend_pass);
|
||||
}
|
||||
|
||||
/* helper to draw SHADOW passes */
|
||||
@@ -932,8 +932,8 @@ static void draw_gpencil_shadow_passes(GPENCIL_Data *vedata, ShadowShaderFxData
|
||||
const float clearcol[4] = {0.0f};
|
||||
|
||||
/* prepare shadow */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_fx);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_fx_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fx_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh, fxd->runtime.fx_sh);
|
||||
|
||||
/* blur shadow */
|
||||
@@ -941,17 +941,17 @@ static void draw_gpencil_shadow_passes(GPENCIL_Data *vedata, ShadowShaderFxData
|
||||
vedata, &fxd->runtime, fxd->samples, fxd->blur[0], fxd->blur[1], &fxd->blur[0]);
|
||||
|
||||
/* resolve */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_b_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_b_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_b_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_b_tx;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_a_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_screen_noblend_pass);
|
||||
}
|
||||
|
||||
/* helper to draw GLOW passes */
|
||||
@@ -968,8 +968,8 @@ static void draw_gpencil_glow_passes(GPENCIL_Data *vedata, GlowShaderFxData *fxd
|
||||
const float clearcol[4] = {0.0f};
|
||||
|
||||
/* prepare glow */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_fx);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_fx, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_fx_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fx_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh, fxd->runtime.fx_sh);
|
||||
|
||||
/* blur glow */
|
||||
@@ -977,8 +977,8 @@ static void draw_gpencil_glow_passes(GPENCIL_Data *vedata, GlowShaderFxData *fxd
|
||||
vedata, &fxd->runtime, fxd->samples, fxd->blur[0], fxd->blur[0], &fxd->blur[0]);
|
||||
|
||||
/* resolve */
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
GPU_framebuffer_bind(fbl->temp_b_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_b_fb, clearcol, 1.0f);
|
||||
|
||||
/* reuses blur field to keep alpha mode */
|
||||
fxd->blur[1] = (fxd->flag & FX_GLOW_USE_ALPHA) ? 1 : 0;
|
||||
@@ -986,12 +986,12 @@ static void draw_gpencil_glow_passes(GPENCIL_Data *vedata, GlowShaderFxData *fxd
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_b_tx;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_b_tx;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_pass_noblend);
|
||||
GPU_framebuffer_bind(fbl->temp_a_fb);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_a_fb, clearcol, 1.0f);
|
||||
DRW_draw_pass(psl->mix_screen_noblend_pass);
|
||||
}
|
||||
|
||||
/* apply all object fx effects */
|
||||
|
@@ -1,17 +1,6 @@
|
||||
in vec4 uvcoordsvar;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D strokeColor;
|
||||
uniform sampler2D strokeDepth;
|
||||
uniform sampler2D blendColor;
|
||||
uniform sampler2D blendDepth;
|
||||
uniform int mode;
|
||||
uniform int mask_layer;
|
||||
uniform int tonemapping;
|
||||
|
||||
#define ON 1
|
||||
#define OFF 0
|
||||
|
||||
#define MODE_REGULAR 0
|
||||
#define MODE_OVERLAY 1
|
||||
@@ -20,138 +9,63 @@ uniform int tonemapping;
|
||||
#define MODE_MULTIPLY 4
|
||||
#define MODE_DIVIDE 5
|
||||
|
||||
float overlay_color(float a, float b)
|
||||
{
|
||||
float rtn;
|
||||
if (a < 0.5) {
|
||||
rtn = 2.0 * a * b;
|
||||
}
|
||||
else {
|
||||
rtn = 1.0 - 2.0 * (1.0 - a) * (1.0 - b);
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
vec4 get_blend_color(int mode, vec4 src_color, vec4 mix_color)
|
||||
{
|
||||
vec4 outcolor;
|
||||
|
||||
if (mix_color.a == 0) {
|
||||
return src_color;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case MODE_REGULAR: {
|
||||
/* premult */
|
||||
src_color = vec4(vec3(src_color.rgb / src_color.a), src_color.a);
|
||||
mix_color = vec4(vec3(mix_color.rgb / mix_color.a), mix_color.a);
|
||||
|
||||
outcolor = vec4(mix(src_color.rgb, mix_color.rgb, mix_color.a), src_color.a);
|
||||
break;
|
||||
}
|
||||
case MODE_OVERLAY: {
|
||||
src_color = vec4(vec3(src_color.rgb / src_color.a), src_color.a);
|
||||
mix_color = vec4(vec3(mix_color.rgb / mix_color.a), mix_color.a);
|
||||
|
||||
mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a);
|
||||
outcolor.r = overlay_color(src_color.r, mix_color.r);
|
||||
outcolor.g = overlay_color(src_color.g, mix_color.g);
|
||||
outcolor.b = overlay_color(src_color.b, mix_color.b);
|
||||
outcolor.a = src_color.a;
|
||||
break;
|
||||
}
|
||||
case MODE_ADD: {
|
||||
mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a);
|
||||
outcolor = src_color + mix_color;
|
||||
outcolor.a = src_color.a;
|
||||
break;
|
||||
}
|
||||
case MODE_SUB: {
|
||||
mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a);
|
||||
outcolor = src_color - mix_color;
|
||||
outcolor.a = clamp(src_color.a - mix_color.a, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case MODE_MULTIPLY: {
|
||||
src_color = vec4(vec3(src_color.rgb / src_color.a), src_color.a);
|
||||
mix_color = vec4(vec3(mix_color.rgb / mix_color.a), mix_color.a);
|
||||
|
||||
mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a);
|
||||
outcolor = src_color * mix_color;
|
||||
outcolor.a = src_color.a;
|
||||
break;
|
||||
}
|
||||
case MODE_DIVIDE: {
|
||||
mix_color.rgb = mix(src_color.rgb, mix_color.rgb, mix_color.a);
|
||||
outcolor = src_color / mix_color;
|
||||
outcolor.a = src_color.a;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
outcolor = mix_color;
|
||||
outcolor.a = src_color.a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return clamp(outcolor, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float linearrgb_to_srgb(float c)
|
||||
{
|
||||
if (c < 0.0031308) {
|
||||
return (c < 0.0) ? 0.0 : c * 12.92;
|
||||
}
|
||||
else {
|
||||
return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 tone(vec4 stroke_color)
|
||||
{
|
||||
if (tonemapping == 1) {
|
||||
vec4 color = vec4(0, 0, 0, stroke_color.a);
|
||||
color.r = linearrgb_to_srgb(stroke_color.r);
|
||||
color.g = linearrgb_to_srgb(stroke_color.g);
|
||||
color.b = linearrgb_to_srgb(stroke_color.b);
|
||||
return color;
|
||||
}
|
||||
else {
|
||||
return stroke_color;
|
||||
}
|
||||
}
|
||||
/* Blend equation is : FragColor0 + FragColor1 * DstColor */
|
||||
layout(location = 0, index = 0) out vec4 FragColor0;
|
||||
layout(location = 0, index = 1) out vec4 FragColor1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 outcolor;
|
||||
ivec2 uv = ivec2(gl_FragCoord.xy);
|
||||
vec4 stroke_color = texelFetch(strokeColor, uv, 0).rgba;
|
||||
float stroke_depth = texelFetch(strokeDepth, uv, 0).r;
|
||||
ivec2 texel = ivec2(gl_FragCoord.xy);
|
||||
vec4 src = texelFetch(strokeColor, texel, 0).rgba;
|
||||
|
||||
vec4 mix_color = texelFetch(blendColor, uv, 0).rgba;
|
||||
float mix_depth = texelFetch(blendDepth, uv, 0).r;
|
||||
|
||||
if (stroke_color.a > 0) {
|
||||
if (mix_color.a > 0) {
|
||||
/* apply blend mode */
|
||||
FragColor = get_blend_color(mode, stroke_color, mix_color);
|
||||
}
|
||||
else {
|
||||
FragColor = stroke_color;
|
||||
}
|
||||
gl_FragDepth = min(stroke_depth, mix_depth);
|
||||
}
|
||||
else {
|
||||
if (mask_layer == ON) {
|
||||
discard;
|
||||
}
|
||||
else {
|
||||
/* if not using mask, return mix color */
|
||||
FragColor = mix_color;
|
||||
gl_FragDepth = mix_depth;
|
||||
}
|
||||
switch (mode) {
|
||||
case MODE_REGULAR:
|
||||
FragColor0 = src;
|
||||
FragColor1 = 1.0 - vec4(src.a);
|
||||
break;
|
||||
case MODE_OVERLAY:
|
||||
/* Original overlay is :
|
||||
* overlay = (a < 0.5) ? (2 * a * b) : (1 - 2 * (1 - a) * (1 - b));
|
||||
* But we are using dual source blending. So we need to rewrite it as a function of b (DST).
|
||||
* overlay = 1 - 2 * (1 - a) * (1 - b);
|
||||
* overlay = 1 + (2 * a - 2) * (1 - b);
|
||||
* overlay = 1 + (2 * a - 2) - (2 * a - 2) * b;
|
||||
* overlay = (2 * a - 1) + (2 - 2 * a) * b;
|
||||
*
|
||||
* With the right coefficient, we can get the 2 * a * b from the same equation.
|
||||
* q0 = 0, q1 = -1;
|
||||
* overlay = (2 * a - 1) * q0 + (2 * q0 - 2 * q1 * a) * b;
|
||||
* overlay = 2 * a * b;
|
||||
* */
|
||||
src.rgb = mix(vec3(0.5), src.rgb, src.a);
|
||||
vec3 q0 = vec3(greaterThanEqual(src.rgb, vec3(0.5)));
|
||||
vec3 q1 = q0 * 2.0 - 1.0;
|
||||
vec3 src2 = 2.0 * src.rgb;
|
||||
FragColor0.rgb = src2 * q0 - q0;
|
||||
FragColor1.rgb = 2.0 * q0 - src2 * q1;
|
||||
break;
|
||||
case MODE_ADD:
|
||||
FragColor0.rgb = src.rgb * src.a;
|
||||
FragColor1.rgb = vec3(1.0);
|
||||
break;
|
||||
case MODE_SUB:
|
||||
FragColor0.rgb = -src.rgb * src.a;
|
||||
FragColor1.rgb = vec3(1.0);
|
||||
break;
|
||||
case MODE_MULTIPLY:
|
||||
FragColor0.rgb = vec3(0.0);
|
||||
FragColor1.rgb = mix(vec3(1.0), src.rgb, src.a);
|
||||
break;
|
||||
case MODE_DIVIDE:
|
||||
FragColor0.rgb = vec3(0.0);
|
||||
FragColor1.rgb = 1.0 / mix(vec3(1.0), src.rgb, src.a);
|
||||
break;
|
||||
default:
|
||||
FragColor0 = vec4(0.0);
|
||||
FragColor1 = vec4(1.0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* apply tone mapping */
|
||||
FragColor = tone(FragColor);
|
||||
FragColor0.a = 1.0 - clamp(dot(vec3(1.0 / 3.0), FragColor1.rgb), 0.0, 1.0);
|
||||
FragColor1.a = 1.0 - FragColor0.a;
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
|
||||
uniform sampler2D strokeDepth;
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 texel = ivec2(gl_FragCoord.xy);
|
||||
gl_FragDepth = texelFetch(strokeDepth, texel, 0).r;
|
||||
}
|
Reference in New Issue
Block a user