diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-01 18:07:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-01 18:07:20 +0300 |
commit | e59cc3a814a851594cb2bdddc729cf413b4180c0 (patch) | |
tree | 57da954f46caf9e8782701e62e805c08a4b3abf2 /source/blender/draw | |
parent | d33801e2bff1e39cefc74f53ae2b5e532cc7d964 (diff) |
Overlay: Port gpencil canvas shader to use shaderCreateInfo
This should have no functional changes.
Diffstat (limited to 'source/blender/draw')
3 files changed, 34 insertions, 17 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.c index 22a10b9d6c4..bd3f87a51c5 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.c @@ -683,15 +683,13 @@ GPUShader *OVERLAY_shader_facing(void) GPUShader *OVERLAY_shader_gpencil_canvas(void) { - OVERLAY_Shaders *sh_data = &e_data.sh_data[0]; + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; if (!sh_data->gpencil_canvas) { - sh_data->gpencil_canvas = GPU_shader_create_from_arrays({ - .vert = (const char *[]){datatoc_common_globals_lib_glsl, - datatoc_common_view_lib_glsl, - datatoc_edit_gpencil_canvas_vert_glsl, - NULL}, - .frag = (const char *[]){datatoc_common_view_lib_glsl, datatoc_extra_frag_glsl, NULL}, - }); + /* TODO(fclem): Support Clipping? Everything is already setup but don't want to change behavior + * without agreement of all gpencil module. */ + sh_data->gpencil_canvas = GPU_shader_create_from_info_name( + 0 ? "overlay_gpencil_canvas_clipped" : "overlay_gpencil_canvas"); } return sh_data->gpencil_canvas; } diff --git a/source/blender/draw/engines/overlay/shaders/edit_gpencil_canvas_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_gpencil_canvas_vert.glsl index 5aa7fe78e4e..47d9439ed80 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_gpencil_canvas_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_gpencil_canvas_vert.glsl @@ -1,13 +1,6 @@ -uniform vec4 color; -uniform vec3 xAxis; -uniform vec3 yAxis; -uniform vec3 origin; -uniform int halfLineCount; - -flat out vec4 finalColor; -flat out vec2 edgeStart; -noperspective out vec2 edgePos; +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) void main() { @@ -28,6 +21,8 @@ void main() gl_Position = point_world_to_ndc(world_pos); + view_clipping_distances(world_pos); + finalColor = color; /* Convert to screen position [0..sizeVp]. */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/extra_info.hh b/source/blender/draw/engines/overlay/shaders/infos/extra_info.hh index 2643f5cd806..786754b1068 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/extra_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/extra_info.hh @@ -251,3 +251,27 @@ GPU_SHADER_CREATE_INFO(overlay_image_clipped) .additional_info("overlay_image", "drw_clipped"); /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name GPencil Canvas + * \{ */ + +GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas) + .do_static_compilation(true) + .vertex_out(overlay_extra_iface) + .push_constant(Type::VEC4, "color") + .push_constant(Type::VEC3, "xAxis") + .push_constant(Type::VEC3, "yAxis") + .push_constant(Type::VEC3, "origin") + .push_constant(Type::INT, "halfLineCount") + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_out(1, Type::VEC4, "lineOutput") + .vertex_source("edit_gpencil_canvas_vert.glsl") + .fragment_source("extra_frag.glsl") + .additional_info("draw_mesh", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas_clipped) + .do_static_compilation(true) + .additional_info("overlay_gpencil_canvas", "drw_clipped"); + +/** \} */ |