diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-10-07 01:16:25 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-10-07 13:43:10 +0300 |
commit | 126d485b837d317ead313c46bcd6545d03391020 (patch) | |
tree | 37c9f9efea017ca9854aa43244ed046c0be1dd35 /source/blender/draw/engines/overlay/shaders | |
parent | a945cf4d0fc38f3c84747767612ad1d748ceb2a0 (diff) |
DRW: Remove screen_vecs
These were only a normalized copy of the XY axes of the inverse viewmat.
But since the viewmatrix is always normalized we can use it directly.
Diffstat (limited to 'source/blender/draw/engines/overlay/shaders')
5 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl index caca123a0c2..ce1ee8ca448 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_mesh_skin_root_vert.glsl @@ -5,8 +5,8 @@ void main() { mat3 imat = mat3(ModelMatrixInverse); - vec3 right = normalize(imat * screenVecs[0].xyz); - vec3 up = normalize(imat * screenVecs[1].xyz); + vec3 right = normalize(imat * ViewMatrixInverse[0].xyz); + vec3 up = normalize(imat * ViewMatrixInverse[1].xyz); vec3 screen_pos = (right * pos.x + up * pos.z) * size; vec4 pos_4d = ModelMatrix * vec4(local_pos + screen_pos, 1.0); gl_Position = drw_view.winmat * (drw_view.viewmat * pos_4d); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_extra_groundline_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_extra_groundline_vert.glsl index ff7aae523e7..bc8ba710d3b 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_extra_groundline_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_extra_groundline_vert.glsl @@ -7,7 +7,7 @@ void main() finalColor = colorLight; /* Relative to DPI scaling. Have constant screen size. */ - vec3 screen_pos = screenVecs[0].xyz * pos.x + screenVecs[1].xyz * pos.y; + vec3 screen_pos = ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y; vec3 p = inst_pos; p.z *= (pos.z == 0.0) ? 0.0 : 1.0; float screen_size = mul_project_m4_v3_zfac(p) * sizePixel; diff --git a/source/blender/draw/engines/overlay/shaders/overlay_extra_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_extra_vert.glsl index acaf04219c0..269da0fd196 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_extra_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_extra_vert.glsl @@ -171,14 +171,14 @@ void main() vec3 world_pos; if ((vclass & VCLASS_SCREENSPACE) != 0) { /* Relative to DPI scaling. Have constant screen size. */ - vec3 screen_pos = screenVecs[0].xyz * vpos.x + screenVecs[1].xyz * vpos.y; + vec3 screen_pos = ViewMatrixInverse[0].xyz * vpos.x + ViewMatrixInverse[1].xyz * vpos.y; vec3 p = (obmat * vec4(vofs, 1.0)).xyz; float screen_size = mul_project_m4_v3_zfac(p) * sizePixel; world_pos = p + screen_pos * screen_size; } else if ((vclass & VCLASS_SCREENALIGNED) != 0) { /* World sized, camera facing geometry. */ - vec3 screen_pos = screenVecs[0].xyz * vpos.x + screenVecs[1].xyz * vpos.y; + vec3 screen_pos = ViewMatrixInverse[0].xyz * vpos.x + ViewMatrixInverse[1].xyz * vpos.y; world_pos = (obmat * vec4(vofs, 1.0)).xyz + screen_pos; } else { diff --git a/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl index 2c81966fe50..b401c3e7b2e 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl @@ -95,9 +95,9 @@ void main() } if (flag_test(grid_flag, SHOW_GRID)) { - /* Using `max(dot(dFdxPos, screenVecs[0]), dot(dFdyPos, screenVecs[1]))` + /* Using `max(dot(dFdxPos, ViewMatrixInverse[0]), dot(dFdyPos, ViewMatrixInverse[1]))` * would be more accurate, but not really necessary. */ - float grid_res = dot(dFdxPos, screenVecs[0].xyz); + float grid_res = dot(dFdxPos, ViewMatrixInverse[0].xyz); /* The grid begins to appear when it comprises 4 pixels. */ grid_res *= 4; diff --git a/source/blender/draw/engines/overlay/shaders/overlay_particle_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_particle_vert.glsl index 48038d0ca17..2c2d3199e45 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_particle_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_particle_vert.glsl @@ -28,7 +28,7 @@ void main() if ((vclass & VCLASS_SCREENALIGNED) != 0) { /* World sized, camera facing geometry. */ - world_pos += (screenVecs[0].xyz * pos.x + screenVecs[1].xyz * pos.y) * draw_size; + world_pos += (ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y) * draw_size; } else { world_pos += rotate(pos, part_rot) * draw_size; |