Cleanup: DRW: Remove drw_view renaming MACROS

This commit is contained in:
Clément Foucault
2022-06-27 12:46:05 +02:00
parent ddc6b86a5b
commit 2b806cb955
29 changed files with 58 additions and 58 deletions

View File

@@ -344,7 +344,7 @@ float stroke_thickness_modulate(float thickness)
}
else {
/* World space point size. */
thickness *= thicknessWorldScale * ProjectionMatrix[1][1] * sizeViewport.y;
thickness *= thicknessWorldScale * drw_view.winmat[1][1] * sizeViewport.y;
}
return thickness;
}

View File

@@ -5,5 +5,5 @@ void main()
int v = gl_VertexID % 3;
float x = -1.0 + float((v & 1) << 2);
float y = -1.0 + float((v & 2) << 1);
gl_Position = ViewProjectionMatrix * (model_matrix * vec4(x, y, 0.0, 1.0));
gl_Position = drw_view.persmat * (model_matrix * vec4(x, y, 0.0, 1.0));
}

View File

@@ -17,8 +17,8 @@ vec2 compute_dir(vec2 v0, vec2 v1, vec2 v2)
mat3 compute_mat(vec4 sphere, vec3 bone_vec, out float z_ofs)
{
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
vec3 cam_ray = (is_persp) ? sphere.xyz - ViewMatrixInverse[3].xyz : -ViewMatrixInverse[2].xyz;
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 cam_ray = (is_persp) ? sphere.xyz - drw_view.viewinv[3].xyz : -drw_view.viewinv[2].xyz;
/* Sphere center distance from the camera (persp) in world space. */
float cam_dist = length(cam_ray);
@@ -88,13 +88,13 @@ vec3 get_outline_point(vec2 pos,
void main()
{
float dst_head = distance(headSphere.xyz, ViewMatrixInverse[3].xyz);
float dst_tail = distance(tailSphere.xyz, ViewMatrixInverse[3].xyz);
// float dst_head = -dot(headSphere.xyz, ViewMatrix[2].xyz);
// float dst_tail = -dot(tailSphere.xyz, ViewMatrix[2].xyz);
float dst_head = distance(headSphere.xyz, drw_view.viewinv[3].xyz);
float dst_tail = distance(tailSphere.xyz, drw_view.viewinv[3].xyz);
// float dst_head = -dot(headSphere.xyz, drw_view.viewmat[2].xyz);
// float dst_tail = -dot(tailSphere.xyz, drw_view.viewmat[2].xyz);
vec4 sph_near, sph_far;
if ((dst_head > dst_tail) && (ProjectionMatrix[3][3] == 0.0)) {
if ((dst_head > dst_tail) && (drw_view.winmat[3][3] == 0.0)) {
sph_near = tailSphere;
sph_far = headSphere;
}

View File

@@ -30,7 +30,7 @@ void main()
sp = bone_mat * sp.xzy + headSphere.xyz;
nor = bone_mat * nor.xzy;
normalView = mat3(ViewMatrix) * nor;
normalView = mat3(drw_view.viewmat) * nor;
finalStateColor = stateColor;
finalBoneColor = boneColor;
@@ -38,5 +38,5 @@ void main()
view_clipping_distances(sp);
vec4 pos_4d = vec4(sp, 1.0);
gl_Position = ViewProjectionMatrix * pos_4d;
gl_Position = drw_view.persmat * pos_4d;
}

View File

@@ -5,7 +5,7 @@ void main(void)
{
finalColor = vec4(geom_in[0].vColSize.rgb, 1.0);
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(geom_in[1].vPos) : vec3(0.0, 0.0, -1.0);
vec3 v10 = geom_in[0].vPos - geom_in[1].vPos;

View File

@@ -14,10 +14,10 @@ void main()
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
vec4 world_pos = model_mat * vec4(pos, 1.0);
vec4 view_pos = ViewMatrix * world_pos;
vec4 view_pos = drw_view.viewmat * world_pos;
geom_in.vPos = view_pos.xyz;
geom_in.pPos = ProjectionMatrix * view_pos;
geom_in.pPos = drw_view.winmat * view_pos;
geom_in.inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0);

View File

@@ -25,7 +25,7 @@ void main()
finalColor.a = 1.0;
vec4 world_pos = model_mat * vec4(pos, 1.0);
gl_Position = ViewProjectionMatrix * world_pos;
gl_Position = drw_view.persmat * world_pos;
view_clipping_distances(world_pos.xyz);
}

View File

@@ -13,10 +13,10 @@ void main()
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
mat4 model_view_matrix = ViewMatrix * model_mat;
mat4 model_view_matrix = drw_view.viewmat * model_mat;
mat4 sphereMatrix = inverse(model_view_matrix);
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
/* This is the local space camera ray (not normalize).
* In perspective mode it's also the viewspace position
@@ -58,8 +58,8 @@ void main()
vec3 cam_pos0 = x_axis * pos.x + y_axis * pos.y + z_axis * z_ofs;
vec4 V = model_view_matrix * vec4(cam_pos0, 1.0);
gl_Position = ProjectionMatrix * V;
vec4 center = ProjectionMatrix * vec4(model_view_matrix[3].xyz, 1.0);
gl_Position = drw_view.winmat * V;
vec4 center = drw_view.winmat * vec4(model_view_matrix[3].xyz, 1.0);
/* Offset away from the center to avoid overlap with solid shape. */
vec2 ofs_dir = normalize(proj(gl_Position) - proj(center));

View File

@@ -5,7 +5,7 @@ void main()
{
const float sphere_radius = 0.05;
bool is_perp = (ProjectionMatrix[3][3] == 0.0);
bool is_perp = (drw_view.winmat[3][3] == 0.0);
vec3 ray_ori_view = (is_perp) ? vec3(0.0) : viewPosition.xyz;
vec3 ray_dir_view = (is_perp) ? viewPosition : vec3(0.0, 0.0, -1.0);

View File

@@ -10,10 +10,10 @@ void main()
vec4 bone_color, state_color;
mat4 model_mat = extract_matrix_packed_data(inst_obmat, state_color, bone_color);
mat4 model_view_matrix = ViewMatrix * model_mat;
mat4 model_view_matrix = drw_view.viewmat * model_mat;
sphereMatrix = inverse(model_view_matrix);
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
/* This is the local space camera ray (not normalize).
* In perspective mode it's also the viewspace position
@@ -65,7 +65,7 @@ void main()
vec4 pos_4d = vec4(cam_pos, 1.0);
vec4 V = model_view_matrix * pos_4d;
gl_Position = ProjectionMatrix * V;
gl_Position = drw_view.winmat * V;
viewPosition = V.xyz;
finalStateColor = state_color.xyz;

View File

@@ -31,12 +31,12 @@ void main()
vec4 boneStart_4d = vec4(boneStart, 1.0);
vec4 boneEnd_4d = vec4(boneEnd, 1.0);
vec4 v0 = ViewMatrix * boneStart_4d;
vec4 v1 = ViewMatrix * boneEnd_4d;
vec4 v0 = drw_view.viewmat * boneStart_4d;
vec4 v1 = drw_view.viewmat * boneEnd_4d;
/* Clip the bone to the camera origin plane (not the clip plane)
* to avoid glitches if one end is behind the camera origin (in persp). */
float clip_dist = (ProjectionMatrix[3][3] == 0.0) ?
float clip_dist = (drw_view.winmat[3][3] == 0.0) ?
-1e-7 :
1e20; /* hardcoded, -1e-8 is giving gliches. */
vec3 bvec = v1.xyz - v0.xyz;
@@ -48,8 +48,8 @@ void main()
v1.xyz = clip_pt;
}
vec4 p0 = ProjectionMatrix * v0;
vec4 p1 = ProjectionMatrix * v1;
vec4 p0 = drw_view.winmat * v0;
vec4 p1 = drw_view.winmat * v1;
float h = (is_head) ? p0.w : p1.w;
@@ -58,7 +58,7 @@ void main()
/* 2D screen aligned pos at the point */
vec2 vpos = pos.x * x_screen_vec + pos.y * y_screen_vec;
vpos *= (ProjectionMatrix[3][3] == 0.0) ? h : 1.0;
vpos *= (drw_view.winmat[3][3] == 0.0) ? h : 1.0;
vpos *= (do_wire) ? 1.0 : 0.5;
if (finalInnerColor.a > 0.0) {

View File

@@ -45,7 +45,7 @@ void main()
if (gl_VertexID == 0) {
if (isConstantScreenSizeNormals) {
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
if (is_persp) {
float dist_fac = length(cameraPos - world_pos);
float cos_fac = dot(cameraForward, cameraVec(world_pos));

View File

@@ -9,7 +9,7 @@ void main()
vec3 up = normalize(imat * screenVecs[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 = ViewProjectionMatrix * pos_4d;
gl_Position = drw_view.persmat * pos_4d;
/* Manual stipple: one segment out of 2 is transparent. */
finalColor = ((gl_VertexID & 1) == 0) ? colorSkinRoot : vec4(0.0);

View File

@@ -74,7 +74,7 @@ void main()
finalColor = EDIT_MESH_facedot_color(norAndFlag.w);
/* Bias Facedot Z position in clipspace. */
gl_Position.z -= (ProjectionMatrix[3][3] == 0.0) ? 0.00035 : 1e-6;
gl_Position.z -= (drw_view.winmat[3][3] == 0.0) ? 0.00035 : 1e-6;
gl_PointSize = sizeFaceDot;
bool occluded = test_occlusion();
@@ -87,7 +87,7 @@ void main()
/* Facing based color blend */
vec3 vpos = point_world_to_view(world_pos);
vec3 view_normal = normalize(normal_object_to_view(vnor) + 1e-4);
vec3 view_vec = (ProjectionMatrix[3][3] == 0.0) ? normalize(vpos) : vec3(0.0, 0.0, 1.0);
vec3 view_vec = (drw_view.winmat[3][3] == 0.0) ? normalize(vpos) : vec3(0.0, 0.0, 1.0);
float facing = dot(view_vec, view_normal);
facing = 1.0 - abs(facing) * 0.2;

View File

@@ -198,8 +198,8 @@ void main()
vec3 edge = obmat[3].xyz - world_pos;
vec3 n0 = normalize(cross(edge, p0 - world_pos));
vec3 n1 = normalize(cross(edge, world_pos - p1));
bool persp = (ProjectionMatrix[3][3] == 0.0);
vec3 V = (persp) ? normalize(ViewMatrixInverse[3].xyz - world_pos) : ViewMatrixInverse[2].xyz;
bool persp = (drw_view.winmat[3][3] == 0.0);
vec3 V = (persp) ? normalize(drw_view.viewinv[3].xyz - world_pos) : drw_view.viewinv[2].xyz;
/* Discard non-silhouette edges. */
bool facing0 = dot(n0, V) > 0.0;
bool facing1 = dot(n1, V) > 0.0;

View File

@@ -53,7 +53,7 @@ void main()
P += cameraPos * plane_axes;
float dist, fade;
bool is_persp = ProjectionMatrix[3][3] == 0.0;
bool is_persp = drw_view.winmat[3][3] == 0.0;
if (is_persp) {
vec3 V = cameraPos - P;
dist = length(V);
@@ -83,7 +83,7 @@ void main()
dist = 1.0; /* Avoid branch after. */
if (flag_test(grid_flag, PLANE_XY)) {
float angle = 1.0 - abs(ViewMatrixInverse[2].z);
float angle = 1.0 - abs(drw_view.viewinv[2].z);
dist = 1.0 + angle * 2.0;
angle *= angle;
fade *= 1.0 - angle * angle;

View File

@@ -39,5 +39,5 @@ void main()
local_pos.z = clamp(local_pos.z, -1.0, 0.0);
}
gl_Position = ViewProjectionMatrix * vec4(real_pos, 1.0);
gl_Position = drw_view.persmat * vec4(real_pos, 1.0);
}

View File

@@ -15,7 +15,7 @@ void main(void)
vec2 edge_dir = compute_dir(interp_in[0].ss_pos, interp_in[1].ss_pos) *
drw_view.viewport_size_inverse;
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
float line_size = float(lineThickness) * sizePixel;
view_clipping_distances_set(gl_in[0]);

View File

@@ -18,7 +18,7 @@ vec2 proj(vec4 pos)
void main()
{
gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
gl_Position = drw_view.persmat * vec4(pos, 1.0);
interp.ss_pos = proj(gl_Position);

View File

@@ -9,7 +9,7 @@
void main()
{
gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
gl_Position = drw_view.persmat * vec4(pos, 1.0);
gl_PointSize = float(pointSize + 2);
int frame = gl_VertexID + cacheStart;

View File

@@ -11,7 +11,7 @@ void vert_from_gl_in(int v)
void main()
{
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(vert[1].pos) : vec3(0.0, 0.0, -1.0);

View File

@@ -22,14 +22,14 @@ void main()
if (!gpStrokeOrder3d) {
/* Stroke order 2D. Project to gpDepthPlane. */
bool is_persp = ProjectionMatrix[3][3] == 0.0;
bool is_persp = drw_view.winmat[3][3] == 0.0;
vec2 uvs = vec2(gl_FragCoord.xy) * drw_view.viewport_size_inverse;
vec3 pos_ndc = vec3(uvs, gl_FragCoord.z) * 2.0 - 1.0;
vec4 pos_world = ViewProjectionMatrixInverse * vec4(pos_ndc, 1.0);
vec4 pos_world = drw_view.persinv * vec4(pos_ndc, 1.0);
vec3 pos = pos_world.xyz / pos_world.w;
vec3 ray_ori = pos;
vec3 ray_dir = (is_persp) ? (ViewMatrixInverse[3].xyz - pos) : ViewMatrixInverse[2].xyz;
vec3 ray_dir = (is_persp) ? (drw_view.viewinv[3].xyz - pos) : drw_view.viewinv[2].xyz;
vec3 isect = ray_plane_intersection(ray_ori, ray_dir, gpDepthPlane);
vec4 ndc = point_world_to_ndc(isect);
gl_FragDepth = (ndc.z / ndc.w) * 0.5 + 0.5;

View File

@@ -23,7 +23,7 @@ void main()
#ifdef USE_DOTS
gl_Position = point_world_to_ndc(world_pos);
/* World sized points. */
gl_PointSize = sizePixel * draw_size * ProjectionMatrix[1][1] * sizeViewport.y / gl_Position.w;
gl_PointSize = sizePixel * draw_size * drw_view.winmat[1][1] * sizeViewport.y / gl_Position.w;
#else
if ((vclass & VCLASS_SCREENALIGNED) != 0) {

View File

@@ -72,7 +72,7 @@ void wire_object_color_get(out vec3 rim_col, out vec3 wire_col)
void main()
{
bool no_attr = all(equal(nor, vec3(0)));
vec3 wnor = no_attr ? ViewMatrixInverse[2].xyz : normalize(normal_object_to_world(nor));
vec3 wnor = no_attr ? drw_view.viewinv[2].xyz : normalize(normal_object_to_world(nor));
vec3 wpos = point_object_to_world(pos);
if (isHair) {
@@ -81,8 +81,8 @@ void main()
wnor = -normalize(mat3(obmat) * nor);
}
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
vec3 V = (is_persp) ? normalize(ViewMatrixInverse[3].xyz - wpos) : ViewMatrixInverse[2].xyz;
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 V = (is_persp) ? normalize(drw_view.viewinv[3].xyz - wpos) : drw_view.viewinv[2].xyz;
float facing = dot(wnor, V);

View File

@@ -31,9 +31,9 @@ void cavity_compute(vec2 screenco,
/* find the offset in screen space by multiplying a point
* in camera space at the depth of the point by the projection matrix. */
vec2 offset;
float homcoord = ProjectionMatrix[2][3] * position.z + ProjectionMatrix[3][3];
offset.x = ProjectionMatrix[0][0] * world_data.cavity_distance / homcoord;
offset.y = ProjectionMatrix[1][1] * world_data.cavity_distance / homcoord;
float homcoord = drw_view.winmat[2][3] * position.z + drw_view.winmat[3][3];
offset.x = drw_view.winmat[0][0] * world_data.cavity_distance / homcoord;
offset.y = drw_view.winmat[1][1] * world_data.cavity_distance / homcoord;
/* convert from -1.0...1.0 range to 0.0..1.0 for easy use with texture coordinates */
offset *= 0.5;

View File

@@ -16,7 +16,7 @@
(dof_aperturesize * (dof_distance / zdepth - 1.0) * dof_invsensorsize)
#define linear_depth(z) \
((ProjectionMatrix[3][3] == 0.0) ? \
((drw_view.winmat[3][3] == 0.0) ? \
(nearFar.x * nearFar.y) / (z * (nearFar.x - nearFar.y) + nearFar.y) : \
(z * 2.0 - 1.0) * nearFar.y)

View File

@@ -43,13 +43,13 @@ void workbench_hair_random_material(float rand,
void main()
{
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
bool is_persp = (drw_view.winmat[3][3] == 0.0);
float time, thick_time, thickness;
vec3 world_pos, tan, binor;
hair_get_pos_tan_binor_time(is_persp,
ModelMatrixInverse,
ViewMatrixInverse[3].xyz,
ViewMatrixInverse[2].xyz,
drw_view.viewinv[3].xyz,
drw_view.viewinv[2].xyz,
world_pos,
tan,
binor,

View File

@@ -24,7 +24,7 @@ float linear_zdepth(float depth, vec4 viewvecs[2], mat4 proj_mat)
*/
float calculate_transparent_weight(void)
{
float z = linear_zdepth(gl_FragCoord.z, ViewVecs, ProjectionMatrix);
float z = linear_zdepth(gl_FragCoord.z, drw_view.viewvecs, drw_view.winmat);
#if 0
/* Eq 10 : Good for surfaces with varying opacity (like particles) */
float a = min(1.0, alpha * 10.0) + 0.01;

View File

@@ -237,7 +237,7 @@ void main()
fragColor = vec4(Lscat, Tr);
#else
vec2 screen_uv = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0).xy);
bool is_persp = ProjectionMatrix[3][3] == 0.0;
bool is_persp = drw_view.winmat[3][3] == 0.0;
vec3 volume_center = ModelMatrix[3].xyz;