diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-09 23:27:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-10 13:14:41 +0300 |
commit | 7f87e6e18f5164db82e636c6b5b449d39cc4300c (patch) | |
tree | 5d3c44dc93123b804553c755951a3db2947dc1a8 /source | |
parent | 0d8ab0eac6045c0e4e3d175d0f7fc70d80072a71 (diff) |
GPencil: Use common_view_lib.glsl
Diffstat (limited to 'source')
8 files changed, 33 insertions, 28 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index ea578187765..33f682b7f63 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -61,6 +61,8 @@ 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_common_view_lib_glsl[]; + /* *********** STATIC *********** */ static GPENCIL_e_data e_data = {NULL}; /* Engine data */ @@ -167,31 +169,37 @@ static void GPENCIL_create_shaders(void) { /* normal fill shader */ if (!e_data.gpencil_fill_sh) { - e_data.gpencil_fill_sh = DRW_shader_create( - datatoc_gpencil_fill_vert_glsl, NULL, datatoc_gpencil_fill_frag_glsl, NULL); + e_data.gpencil_fill_sh = DRW_shader_create_with_lib(datatoc_gpencil_fill_vert_glsl, + NULL, + datatoc_gpencil_fill_frag_glsl, + datatoc_common_view_lib_glsl, + NULL); } /* normal stroke shader using geometry to display lines (line mode) */ if (!e_data.gpencil_stroke_sh) { - e_data.gpencil_stroke_sh = DRW_shader_create(datatoc_gpencil_stroke_vert_glsl, - datatoc_gpencil_stroke_geom_glsl, - datatoc_gpencil_stroke_frag_glsl, - NULL); + e_data.gpencil_stroke_sh = DRW_shader_create_with_lib(datatoc_gpencil_stroke_vert_glsl, + datatoc_gpencil_stroke_geom_glsl, + datatoc_gpencil_stroke_frag_glsl, + datatoc_common_view_lib_glsl, + NULL); } /* dot/rectangle mode for normal strokes using geometry */ if (!e_data.gpencil_point_sh) { - e_data.gpencil_point_sh = DRW_shader_create(datatoc_gpencil_point_vert_glsl, - datatoc_gpencil_point_geom_glsl, - datatoc_gpencil_point_frag_glsl, - NULL); + e_data.gpencil_point_sh = DRW_shader_create_with_lib(datatoc_gpencil_point_vert_glsl, + datatoc_gpencil_point_geom_glsl, + datatoc_gpencil_point_frag_glsl, + datatoc_common_view_lib_glsl, + NULL); } /* used for edit points or strokes with one point only */ if (!e_data.gpencil_edit_point_sh) { - e_data.gpencil_edit_point_sh = DRW_shader_create(datatoc_gpencil_edit_point_vert_glsl, - datatoc_gpencil_edit_point_geom_glsl, - datatoc_gpencil_edit_point_frag_glsl, - NULL); + e_data.gpencil_edit_point_sh = DRW_shader_create_with_lib(datatoc_gpencil_edit_point_vert_glsl, + datatoc_gpencil_edit_point_geom_glsl, + datatoc_gpencil_edit_point_frag_glsl, + datatoc_common_view_lib_glsl, + NULL); } /* used for edit lines for edit modes */ diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl index 8c3fd022004..e0634a7d1a7 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl @@ -1,4 +1,3 @@ -uniform mat4 ModelViewProjectionMatrix; uniform vec2 Viewport; layout(points) in; diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl index eea28755ae6..12e7f3ee516 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl @@ -1,4 +1,4 @@ -uniform mat4 ModelViewProjectionMatrix; +uniform mat4 ModelMatrix; in vec3 pos; in vec4 color; @@ -9,7 +9,7 @@ out float finalThickness; void main() { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + gl_Position = point_object_to_ndc(pos); finalColor = color; finalThickness = size; } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl index d71f57eb98c..4517b68b5e6 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl @@ -1,14 +1,15 @@ -uniform mat4 ModelViewProjectionMatrix; +uniform mat4 ModelMatrix; in vec3 pos; in vec4 color; in vec2 texCoord; + out vec4 finalColor; out vec2 texCoord_interp; void main(void) { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + gl_Position = point_object_to_ndc(pos); finalColor = color; texCoord_interp = texCoord; } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl index af767245f63..e6eb638dd64 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl @@ -1,4 +1,3 @@ -uniform mat4 ModelViewProjectionMatrix; uniform vec2 Viewport; uniform int xraymode; uniform int use_follow_path; diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl index 9cef7601770..355d5ef1b0f 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl @@ -1,5 +1,5 @@ -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 ProjectionMatrix; + +uniform mat4 ModelMatrix; uniform float pixsize; /* rv3d->pixsize */ uniform int keep_size; @@ -32,8 +32,8 @@ float defaultpixsize = pixsize * (1000.0 / pixfactor); void main() { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); - finalprev_pos = ModelViewProjectionMatrix * vec4(prev_pos, 1.0); + gl_Position = point_object_to_ndc(pos); + finalprev_pos = point_object_to_ndc(prev_pos); finalColor = color; if (keep_size == TRUE) { diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl index b90f5b33a57..9ea96806481 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl @@ -1,4 +1,3 @@ -uniform mat4 ModelViewProjectionMatrix; uniform vec2 Viewport; uniform int xraymode; uniform int color_type; diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl index 946b39c006a..4e2ec784385 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl @@ -1,5 +1,4 @@ -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 ProjectionMatrix; +uniform mat4 ModelMatrix; uniform float pixsize; /* rv3d->pixsize */ uniform int keep_size; @@ -30,7 +29,7 @@ float defaultpixsize = pixsize * (1000.0 / pixfactor); void main(void) { - gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + gl_Position = point_object_to_ndc(pos); finalColor = color; if (keep_size == TRUE) { |