Cleanup: DRW: Remove legacy common_view_lib.glsl
No functional changes. Only moving and renaming stuff. Pull Request: https://projects.blender.org/blender/blender/pulls/131558
This commit is contained in:
committed by
Clément Foucault
parent
4938ac7fa5
commit
1ac4651778
@@ -567,7 +567,6 @@ set(GLSL_SRC
|
||||
intern/shaders/common_subdiv_vbo_lnor_comp.glsl
|
||||
intern/shaders/common_subdiv_vbo_sculpt_data_comp.glsl
|
||||
intern/shaders/common_view_clipping_lib.glsl
|
||||
intern/shaders/common_view_lib.glsl
|
||||
intern/shaders/draw_command_generate_comp.glsl
|
||||
intern/shaders/draw_debug_draw_display_frag.glsl
|
||||
intern/shaders/draw_debug_draw_display_vert.glsl
|
||||
|
||||
@@ -28,7 +28,7 @@ packed_float4 g_color;
|
||||
#ifdef OBINFO_LIB
|
||||
vec3 attr_load_orco(vec4 orco)
|
||||
{
|
||||
vec3 lP = point_world_to_object(interp.P);
|
||||
vec3 lP = drw_point_world_to_object(interp.P);
|
||||
return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 image_pos = vec3(pos.x, pos.y, 0.0);
|
||||
uv_screen = image_pos.xy;
|
||||
|
||||
vec4 position = point_world_to_ndc(image_pos);
|
||||
vec4 position = drw_point_world_to_homogenous(image_pos);
|
||||
position.z = 0.0;
|
||||
gl_Position = position;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 image_pos = vec3(pos.x, pos.y, 0.0);
|
||||
uv_image = uv;
|
||||
|
||||
vec4 position = point_world_to_ndc(image_pos);
|
||||
vec4 position = drw_point_world_to_homogenous(image_pos);
|
||||
position.z = 0.0;
|
||||
gl_Position = position;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,20 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef GPU_SHADER
|
||||
# include "gpu_glsl_cpp_stubs.hh"
|
||||
|
||||
# include "draw_common_shader_shared.hh"
|
||||
#endif
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
GPU_SHADER_CREATE_INFO(draw_globals)
|
||||
TYPEDEF_SOURCE("draw_common_shader_shared.hh")
|
||||
UNIFORM_BUF_FREQ(OVERLAY_GLOBALS_SLOT, GlobalsUboStorage, globalsBlock, PASS)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_clipped)
|
||||
DEFINE("OVERLAY_NEXT") /* Needed for view_clipping_lib. */
|
||||
DEFINE("USE_WORLD_CLIP_PLANES")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
vec3 sphere_project(float ax, float az)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ void main()
|
||||
pos.y * abs((pos.y > 0.0) ? amax.y : amin.y));
|
||||
|
||||
vec3 world_pos = (model_mat * vec4(final_pos, 1.0)).xyz;
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
finalColor = data_buf[gl_InstanceID].color_;
|
||||
|
||||
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/* project to screen space */
|
||||
@@ -129,9 +129,9 @@ void main()
|
||||
|
||||
view_clipping_distances(wpos1);
|
||||
|
||||
vec4 p0 = point_world_to_ndc(wpos0);
|
||||
vec4 p1 = point_world_to_ndc(wpos1);
|
||||
vec4 p2 = point_world_to_ndc(wpos2);
|
||||
vec4 p0 = drw_point_world_to_homogenous(wpos0);
|
||||
vec4 p1 = drw_point_world_to_homogenous(wpos1);
|
||||
vec4 p2 = drw_point_world_to_homogenous(wpos2);
|
||||
|
||||
gl_Position = p1;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
struct VertIn {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -17,7 +18,7 @@ void main()
|
||||
/* This is slow and run per vertex, but it's still faster than
|
||||
* doing it per instance on CPU and sending it on via instance attribute. */
|
||||
mat3 normal_mat = transpose(inverse(to_float3x3(model_mat)));
|
||||
vec3 normal = normalize(normal_world_to_view(normal_mat * nor));
|
||||
vec3 normal = normalize(drw_normal_world_to_view(normal_mat * nor));
|
||||
|
||||
inverted = int(dot(cross(model_mat[0].xyz, model_mat[1].xyz), model_mat[2].xyz) < 0.0);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
struct VertIn {
|
||||
@@ -38,7 +39,7 @@ VertOut vertex_main(VertIn v_in)
|
||||
|
||||
VertOut v_out;
|
||||
v_out.world_pos = (model_mat * vec4(v_in.lP, 1.0)).xyz;
|
||||
v_out.gpu_position = point_world_to_ndc(v_out.world_pos);
|
||||
v_out.gpu_position = drw_point_world_to_homogenous(v_out.world_pos);
|
||||
|
||||
v_out.finalColor.rgb = mix(state_color.rgb, bone_color.rgb, 0.5);
|
||||
v_out.finalColor.a = 1.0;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/* project to screen space */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -54,7 +54,7 @@ void main()
|
||||
t /= ray_len;
|
||||
|
||||
#ifndef SELECT_ENABLE
|
||||
gl_FragDepth = get_depth_from_view_z(ray_dir_view.z * t + ray_ori_view.z);
|
||||
gl_FragDepth = drw_depth_view_to_screen(ray_dir_view.z * t + ray_ori_view.z);
|
||||
#endif
|
||||
select_id_output(select_id);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/* Sphere radius */
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -14,7 +15,7 @@ void main()
|
||||
finalColor.a = 1.0;
|
||||
|
||||
vec3 world_pos = data_buf[gl_VertexID].pos_.xyz;
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = boundbox[gl_VertexID];
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Result in a position at 1.0 (far plane). Small epsilon to avoid precision issue.
|
||||
* This mimics the effect of infinite projection matrix
|
||||
|
||||
@@ -4,8 +4,81 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#define OVERLAY_UV_LINE_STYLE_OUTLINE 0
|
||||
#define OVERLAY_UV_LINE_STYLE_DASH 1
|
||||
#define OVERLAY_UV_LINE_STYLE_BLACK 2
|
||||
#define OVERLAY_UV_LINE_STYLE_WHITE 3
|
||||
#define OVERLAY_UV_LINE_STYLE_SHADOW 4
|
||||
|
||||
/* Wire Color Types, matching eV3DShadingColorType. */
|
||||
#define V3D_SHADING_SINGLE_COLOR 2
|
||||
#define V3D_SHADING_OBJECT_COLOR 4
|
||||
#define V3D_SHADING_RANDOM_COLOR 1
|
||||
|
||||
#define DRW_BASE_SELECTED (1 << 1)
|
||||
#define DRW_BASE_FROM_DUPLI (1 << 2)
|
||||
#define DRW_BASE_FROM_SET (1 << 3)
|
||||
#define DRW_BASE_ACTIVE (1 << 4)
|
||||
|
||||
mat4 extract_matrix_packed_data(mat4 mat, out vec4 dataA, out vec4 dataB)
|
||||
{
|
||||
const float div = 1.0 / 255.0;
|
||||
int a = int(mat[0][3]);
|
||||
int b = int(mat[1][3]);
|
||||
int c = int(mat[2][3]);
|
||||
int d = int(mat[3][3]);
|
||||
dataA = vec4(a & 0xFF, a >> 8, b & 0xFF, b >> 8) * div;
|
||||
dataB = vec4(c & 0xFF, c >> 8, d & 0xFF, d >> 8) * div;
|
||||
mat[0][3] = mat[1][3] = mat[2][3] = 0.0;
|
||||
mat[3][3] = 1.0;
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* edge_start and edge_pos needs to be in the range [0..sizeViewport]. */
|
||||
vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 edge_pos)
|
||||
{
|
||||
vec2 edge = edge_start - edge_pos;
|
||||
float len = length(edge);
|
||||
if (len > 0.0) {
|
||||
edge /= len;
|
||||
vec2 perp = vec2(-edge.y, edge.x);
|
||||
float dist = dot(perp, frag_co - edge_start);
|
||||
/* Add 0.1 to differentiate with cleared pixels. */
|
||||
return vec4(perp * 0.5 + 0.5, dist * 0.25 + 0.5 + 0.1, 1.0);
|
||||
}
|
||||
else {
|
||||
/* Default line if the origin is perfectly aligned with a pixel. */
|
||||
return vec4(1.0, 0.0, 0.5 + 0.1, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/* View-space Z is used to adjust for perspective projection.
|
||||
* Homogenous W is used to convert from NDC to homogenous space.
|
||||
* Offset is in view-space, so positive values are closer to the camera. */
|
||||
float get_homogenous_z_offset(mat4x4 winmat, float vs_z, float hs_w, float vs_offset)
|
||||
{
|
||||
if (vs_offset == 0.0) {
|
||||
/* Don't calculate homogenous offset if view-space offset is zero. */
|
||||
return 0.0;
|
||||
}
|
||||
else if (winmat[3][3] == 0.0) {
|
||||
/* Clamp offset to half of Z to avoid floating point precision errors. */
|
||||
vs_offset = min(vs_offset, vs_z * -0.5);
|
||||
/* From "Projection Matrix Tricks" by Eric Lengyel:
|
||||
* http://www.terathon.com/gdc07_lengyel.pdf (p. 24 Depth Modification) */
|
||||
return winmat[3][2] * (vs_offset / (vs_z * (vs_z + vs_offset))) * hs_w;
|
||||
}
|
||||
else {
|
||||
return winmat[2][2] * vs_offset * hs_w;
|
||||
}
|
||||
}
|
||||
|
||||
float mul_project_m4_v3_zfac(float pixel_fac, vec3 co)
|
||||
{
|
||||
vec3 vP = drw_point_world_to_view(co).xyz;
|
||||
float4x4 winmat = drw_view.winmat;
|
||||
return pixel_fac *
|
||||
(winmat[0][3] * vP.x + winmat[1][3] * vP.y + winmat[2][3] * vP.z + winmat[3][3]);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
|
||||
#include "common_hair_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(drw_CustomID);
|
||||
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
|
||||
float time, thick_time, thickness;
|
||||
vec3 world_pos, tan, binor;
|
||||
@@ -27,7 +26,7 @@ void main()
|
||||
thickness,
|
||||
thick_time);
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ void main()
|
||||
vec3 ray_ori = pos;
|
||||
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);
|
||||
vec4 ndc = drw_point_world_to_homogenous(isect);
|
||||
gl_FragDepth = (ndc.z / ndc.w) * 0.5 + 0.5;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_gpencil_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -4,20 +4,19 @@
|
||||
|
||||
#include "common_pointcloud_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(drw_CustomID);
|
||||
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos, world_nor;
|
||||
float world_radius;
|
||||
pointcloud_get_pos_nor_radius(world_pos, world_nor, world_radius);
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
#ifdef CONSERVATIVE_RASTER
|
||||
/* Avoid expense of geometry shader by ensuring rastered point-cloud primitive
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
select_id_set(drw_CustomID);
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
@@ -35,8 +36,8 @@ VertOut vertex_main(VertIn vert_in)
|
||||
{
|
||||
VertOut vert;
|
||||
vert.flag = vert_in.e_data;
|
||||
vert.ws_P = point_object_to_world(vert_in.ls_P);
|
||||
vert.gpu_position = point_world_to_ndc(vert.ws_P);
|
||||
vert.ws_P = drw_point_object_to_world(vert_in.ls_P);
|
||||
vert.gpu_position = drw_point_world_to_homogenous(vert.ws_P);
|
||||
return vert;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
/* Reuse the FREESTYLE flag to determine is GPencil. */
|
||||
bool is_gpencil = ((data & EDGE_FREESTYLE) != 0u);
|
||||
if ((data & VERT_SELECTED) != 0u) {
|
||||
@@ -23,8 +22,8 @@ void main()
|
||||
finalColor = (!is_gpencil) ? colorVertex : colorGpencilVertex;
|
||||
}
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
gl_PointSize = (!is_gpencil) ? sizeVertex * 2.0 : sizeVertexGpencil * 2.0;
|
||||
view_clipping_distances(world_pos);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
|
||||
@@ -36,8 +37,8 @@ void main()
|
||||
ls_P += normalSize * radius * (flip * ls_N - ls_T);
|
||||
}
|
||||
|
||||
vec3 world_pos = point_object_to_world(ls_P);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(ls_P);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
finalColor = colorWireEdit;
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 final_pos = pos;
|
||||
|
||||
float flip = (gl_InstanceID != 0) ? -1.0 : 1.0;
|
||||
@@ -17,8 +16,8 @@ void main()
|
||||
final_pos += normalSize * rad * (flip * nor - tan);
|
||||
}
|
||||
|
||||
vec3 world_pos = point_object_to_world(final_pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(final_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
finalColor = colorWireEdit;
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
@@ -43,8 +44,8 @@ VertOut vertex_main(VertIn vert_in)
|
||||
{
|
||||
VertOut vert;
|
||||
vert.flag = vert_in.e_data;
|
||||
vert.ws_P = point_object_to_world(vert_in.ls_P);
|
||||
vert.gpu_position = point_world_to_ndc(vert.ws_P);
|
||||
vert.ws_P = drw_point_object_to_world(vert_in.ls_P);
|
||||
vert.gpu_position = drw_point_world_to_homogenous(vert.ws_P);
|
||||
vert.sel = vert_in.sel;
|
||||
return vert;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec2 pos;
|
||||
pos.x = float(gl_VertexID % 2);
|
||||
pos.y = float(gl_VertexID / 2) / float(halfLineCount - 1);
|
||||
@@ -22,7 +20,7 @@ void main()
|
||||
|
||||
vec3 world_pos = xAxis * pos.x + yAxis * pos.y + origin;
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void discard_vert()
|
||||
{
|
||||
@@ -36,10 +37,8 @@ vec3 weight_to_rgb(float t)
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
bool is_multiframe = (vflag & GP_EDIT_MULTIFRAME) != 0u;
|
||||
bool is_stroke_sel = (vflag & GP_EDIT_STROKE_SELECTED) != 0u;
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
if ((data & VERT_SELECTED) != 0u) {
|
||||
finalColor = colorVertexSelect;
|
||||
}
|
||||
@@ -19,8 +18,8 @@ void main()
|
||||
finalColor = colorVertex;
|
||||
}
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Small offset in Z */
|
||||
gl_Position.z -= 3e-4;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#define no_active_weight 666.0
|
||||
|
||||
@@ -24,12 +25,10 @@ vec3 weight_to_rgb(float t)
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
finalColor = vec4(weight_to_rgb(weight), 1.0);
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
vec3 weight_to_rgb(float t)
|
||||
{
|
||||
@@ -22,10 +23,8 @@ vec3 weight_to_rgb(float t)
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
weightColor = vec4(weight_to_rgb(weight), 1.0);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
vec3 view_pos = point_world_to_view(world_pos);
|
||||
gl_Position = point_view_to_ndc(view_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
vec3 view_pos = drw_point_world_to_view(world_pos);
|
||||
gl_Position = drw_point_view_to_homogenous(view_pos);
|
||||
|
||||
/* Offset Z position for retopology overlay. */
|
||||
gl_Position.z += get_homogenous_z_offset(view_pos.z, gl_Position.w, retopologyOffset);
|
||||
gl_Position.z += get_homogenous_z_offset(
|
||||
ProjectionMatrix, view_pos.z, gl_Position.w, retopologyOffset);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "overlay_edit_mesh_common_lib.glsl"
|
||||
|
||||
struct VertIn {
|
||||
@@ -43,17 +45,15 @@ struct VertOut {
|
||||
|
||||
VertOut vertex_main(VertIn vert_in)
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
VertOut vert_out;
|
||||
|
||||
vert_out.world_position = point_object_to_world(vert_in.lP);
|
||||
vec3 view_pos = point_world_to_view(vert_out.world_position);
|
||||
vert_out.gpu_position = point_view_to_ndc(view_pos);
|
||||
vert_out.world_position = drw_point_object_to_world(vert_in.lP);
|
||||
vec3 view_pos = drw_point_world_to_view(vert_out.world_position);
|
||||
vert_out.gpu_position = drw_point_view_to_homogenous(view_pos);
|
||||
|
||||
/* Offset Z position for retopology overlay. */
|
||||
vert_out.gpu_position.z += get_homogenous_z_offset(
|
||||
view_pos.z, vert_out.gpu_position.w, retopologyOffset);
|
||||
drw_view.winmat, view_pos.z, vert_out.gpu_position.w, retopologyOffset);
|
||||
|
||||
uvec4 m_data = vert_in.e_data & uvec4(dataMask);
|
||||
|
||||
@@ -116,7 +116,7 @@ VertOut vertex_main(VertIn vert_in)
|
||||
|
||||
#if !defined(FACE)
|
||||
/* Facing based color blend */
|
||||
vec3 view_normal = normalize(normal_object_to_view(vert_in.lN) + 1e-4);
|
||||
vec3 view_normal = normalize(drw_normal_object_to_view(vert_in.lN) + 1e-4);
|
||||
vec3 view_vec = (drw_view.winmat[3][3] == 0.0) ? normalize(view_pos) : vec3(0.0, 0.0, 1.0);
|
||||
float facing = dot(view_vec, view_normal);
|
||||
facing = 1.0 - abs(facing) * 0.2;
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
#include "gpu_shader_index_load_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
|
||||
bool test_occlusion()
|
||||
{
|
||||
@@ -15,8 +17,6 @@ bool test_occlusion()
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
/* Avoid undefined behavior after return. */
|
||||
finalColor = vec4(0.0);
|
||||
gl_Position = vec4(0.0);
|
||||
@@ -109,19 +109,20 @@ void main()
|
||||
vec3 ls_pos = pos;
|
||||
#endif
|
||||
|
||||
vec3 n = normalize(normal_object_to_world(nor));
|
||||
vec3 world_pos = point_object_to_world(ls_pos);
|
||||
vec3 n = normalize(drw_normal_object_to_world(nor));
|
||||
vec3 world_pos = drw_point_object_to_world(ls_pos);
|
||||
|
||||
if ((gl_VertexID & 1) == 0) {
|
||||
if (isConstantScreenSizeNormals) {
|
||||
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));
|
||||
world_pos += n * normalScreenSize * dist_fac * cos_fac * pixelFac * sizePixel;
|
||||
float dist_fac = length(drw_view_position() - world_pos);
|
||||
float cos_fac = dot(drw_view_forward(), drw_world_incident_vector(world_pos));
|
||||
world_pos += n * normalScreenSize * dist_fac * cos_fac * globalsBlock.pixel_fac *
|
||||
sizePixel;
|
||||
}
|
||||
else {
|
||||
float frustrum_fac = mul_project_m4_v3_zfac(n) * sizePixel;
|
||||
float frustrum_fac = mul_project_m4_v3_zfac(globalsBlock.pixel_fac, n) * sizePixel;
|
||||
world_pos += n * normalScreenSize * frustrum_fac;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,7 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
finalColor.a *= (test_occlusion()) ? alpha : 1.0;
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "overlay_edit_mesh_common_lib.glsl"
|
||||
|
||||
#ifdef EDGE
|
||||
@@ -29,14 +31,13 @@ vec3 non_linear_blend_color(vec3 col1, vec3 col2, float fac)
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
vec3 view_pos = point_world_to_view(world_pos);
|
||||
gl_Position = point_view_to_ndc(view_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
vec3 view_pos = drw_point_world_to_view(world_pos);
|
||||
gl_Position = drw_point_view_to_homogenous(view_pos);
|
||||
|
||||
/* Offset Z position for retopology overlay. */
|
||||
gl_Position.z += get_homogenous_z_offset(view_pos.z, gl_Position.w, retopologyOffset);
|
||||
gl_Position.z += get_homogenous_z_offset(
|
||||
ProjectionMatrix, view_pos.z, gl_Position.w, retopologyOffset);
|
||||
|
||||
uvec4 m_data = data & uvec4(dataMask);
|
||||
|
||||
@@ -97,7 +98,7 @@ void main()
|
||||
|
||||
#if !defined(FACE)
|
||||
/* Facing based color blend */
|
||||
vec3 view_normal = normalize(normal_object_to_view(vnor) + 1e-4);
|
||||
vec3 view_normal = normalize(drw_normal_object_to_view(vnor) + 1e-4);
|
||||
vec3 view_vec = (drw_view.winmat[3][3] == 0.0) ? normalize(view_pos) : vec3(0.0, 0.0, 1.0);
|
||||
float facing = dot(view_vec, view_normal);
|
||||
facing = 1.0 - abs(facing) * 0.2;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#define no_active_weight 666.0
|
||||
|
||||
@@ -39,8 +40,8 @@ void main()
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
float end_point_size_factor = 1.0f;
|
||||
|
||||
if (useWeight) {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#define no_active_weight 666.0
|
||||
|
||||
@@ -24,8 +25,8 @@ vec3 weight_to_rgb(float t)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
if (useWeight) {
|
||||
finalColor = vec4(weight_to_rgb(selection), 1.0);
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = vec3(au, 0.0);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
finalColor = ((flag & FACE_UV_SELECT) != 0u) ? colorFaceDot : vec4(colorWire.rgb, 1.0);
|
||||
gl_PointSize = pointSize;
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = vec3(au, 0.0);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
bool is_selected = (flag & FACE_UV_SELECT) != 0u;
|
||||
bool is_active = (flag & FACE_UV_ACTIVE) != 0u;
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
/* `pos` contains the coordinates of a quad (-1..1). but we need the coordinates of an image
|
||||
* plane (0..1) */
|
||||
vec3 image_pos = pos * 0.5 + 0.5;
|
||||
gl_Position = point_world_to_ndc(vec3(image_pos.xy * brush_scale + brush_offset, 0.0));
|
||||
gl_Position = drw_point_world_to_homogenous(
|
||||
vec3(image_pos.xy * brush_scale + brush_offset, 0.0));
|
||||
uvs = image_pos.xy;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
vec3 weight_to_rgb(float weight)
|
||||
{
|
||||
@@ -68,7 +69,7 @@ float area_ratio_to_stretch(float ratio, float tot_ratio)
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = vec3(pos, 0.0);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
#ifdef STRETCH_ANGLE
|
||||
vec2 v1 = angle_to_v2(uv_angles.x * M_PI);
|
||||
|
||||
@@ -2,16 +2,12 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
|
||||
#ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
in vec3 pos;
|
||||
#endif
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
/* `pos` contains the coordinates of a quad (-1..1). but we need the coordinates of an image
|
||||
* plane (0..1) */
|
||||
vec3 image_pos = pos * 0.5 + 0.5;
|
||||
gl_Position = point_world_to_ndc(tile_scale * image_pos + tile_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(tile_scale * image_pos + tile_pos);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -20,7 +21,7 @@ void main()
|
||||
* Vertices are between 0.0 and 0.2, Edges between 0.2 and 0.4
|
||||
* actual pixels are at 0.75, 1.0 is used for the background. */
|
||||
float depth = is_selected ? (is_pinned ? 0.05 : 0.10) : 0.15;
|
||||
gl_Position = vec4(point_world_to_ndc(world_pos).xy, depth, 1.0);
|
||||
gl_Position = vec4(drw_point_world_to_homogenous(world_pos).xy, depth, 1.0);
|
||||
gl_PointSize = pointSize;
|
||||
|
||||
/* calculate concentric radii in pixels */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -16,10 +17,10 @@ void main()
|
||||
vec3 inst_pos = data_buf[gl_InstanceID].xyz;
|
||||
vec3 p = inst_pos;
|
||||
p.z *= (pos.z == 0.0) ? 0.0 : 1.0;
|
||||
float screen_size = mul_project_m4_v3_zfac(p) * sizePixel;
|
||||
float screen_size = mul_project_m4_v3_zfac(globalsBlock.pixel_fac, p) * sizePixel;
|
||||
vec3 world_pos = p + screen_pos * screen_size;
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Convert to screen position [0..sizeVp]. */
|
||||
edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
vec4 color_from_id(float color_id)
|
||||
@@ -47,7 +48,7 @@ void main()
|
||||
ls_cell_location = ls_cell_location * 2.0 - 1.0;
|
||||
|
||||
vec3 ws_cell_location = (model_mat * vec4(ls_cell_location, 1.0)).xyz;
|
||||
gl_Position = point_world_to_ndc(ws_cell_location);
|
||||
gl_Position = drw_point_world_to_homogenous(ws_cell_location);
|
||||
gl_PointSize = sizeVertex * 2.0;
|
||||
|
||||
finalColor = color_from_id(color_id);
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
finalColor = data_buf[gl_VertexID].color_;
|
||||
|
||||
vec3 world_pos = (ModelMatrix * vec4(data_buf[gl_VertexID].pos_.xyz, 1.0)).xyz;
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
gl_PointSize = sizeVertex * 2.0;
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(in_select_buf[gl_VertexID]);
|
||||
|
||||
vec3 world_pos = point_object_to_world(data_buf[gl_VertexID].pos_.xyz);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(data_buf[gl_VertexID].pos_.xyz);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
gl_PointSize = sizeObjectCenter;
|
||||
float radius = 0.5 * sizeObjectCenter;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
#define lamp_area_size inst_data.xy
|
||||
@@ -185,7 +186,7 @@ void main()
|
||||
/* Relative to DPI scaling. Have constant screen size. */
|
||||
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;
|
||||
float screen_size = mul_project_m4_v3_zfac(globalsBlock.pixel_fac, p) * sizePixel;
|
||||
world_pos = p + screen_pos * screen_size;
|
||||
}
|
||||
else if ((vclass & VCLASS_SCREENALIGNED) != 0) {
|
||||
@@ -221,7 +222,7 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Convert to screen position [0..sizeVp]. */
|
||||
edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
vec2 screen_position(vec4 p)
|
||||
@@ -19,8 +20,8 @@ void main()
|
||||
select_id_set(in_select_buf[gl_InstanceID]);
|
||||
#endif
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
#if defined(SELECT_ENABLE)
|
||||
/* HACK: to avoid losing sub-pixel object in selections, we add a bit of randomness to the
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define GRID_LINE_STEP(dist) smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist)
|
||||
|
||||
#include "common_math_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
float get_grid(vec2 co, vec2 fwidthCos, vec2 grid_scale)
|
||||
{
|
||||
@@ -59,12 +59,12 @@ void main()
|
||||
vec3 dFdxPos = dFdx(P);
|
||||
vec3 dFdyPos = dFdy(P);
|
||||
vec3 fwidthPos = abs(dFdxPos) + abs(dFdyPos);
|
||||
P += cameraPos * plane_axes;
|
||||
P += drw_view_position() * plane_axes;
|
||||
|
||||
float dist, fade;
|
||||
bool is_persp = drw_view.winmat[3][3] == 0.0;
|
||||
if (is_persp) {
|
||||
vec3 V = cameraPos - P;
|
||||
vec3 V = drw_view_position() - P;
|
||||
dist = length(V);
|
||||
V /= dist;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "common_math_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -32,7 +32,7 @@ void main()
|
||||
|
||||
local_pos = vert_pos;
|
||||
|
||||
vec3 real_pos = cameraPos * plane_axes + vert_pos * grid_buf.size.xyz;
|
||||
vec3 real_pos = drw_view_position() * plane_axes + vert_pos * grid_buf.size.xyz;
|
||||
|
||||
/* Used for additional Z axis */
|
||||
if (flag_test(grid_flag, CLIP_ZPOS)) {
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
select_id_set(drw_CustomID);
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
if (isCameraBackground) {
|
||||
/* Model matrix converts to view position to avoid jittering (see #91398). */
|
||||
#ifdef DEPTH_BIAS
|
||||
gl_Position = depth_bias_winmat * vec4(world_pos, 1.0);
|
||||
#else
|
||||
gl_Position = point_view_to_ndc(world_pos);
|
||||
gl_Position = drw_point_view_to_homogenous(world_pos);
|
||||
#endif
|
||||
/* Camera background images are not really part of the 3D space.
|
||||
* It makes no sense to apply clipping on them. */
|
||||
@@ -25,7 +26,7 @@ void main()
|
||||
#ifdef DEPTH_BIAS
|
||||
gl_Position = depth_bias_winmat * (ViewMatrix * vec4(world_pos, 1.0));
|
||||
#else
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
#endif
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#define pointSize mpathPointSettings.x
|
||||
#define frameCurrent mpathPointSettings.y
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
|
||||
#define XPOS (1 << 0)
|
||||
#define XNEG (1 << 1)
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_hair_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
@@ -32,7 +33,7 @@ uint outline_colorid_get()
|
||||
|
||||
/* Replace top 2 bits (of the 16bit output) by outlineId.
|
||||
* This leaves 16K different IDs to create outlines between objects.
|
||||
* `vec3 world_pos = point_object_to_world(pos);`
|
||||
* `vec3 world_pos = drw_point_object_to_world(pos);`
|
||||
* `SHIFT = (32 - (16 - 2))`. */
|
||||
#define SHIFT 18u
|
||||
|
||||
@@ -53,7 +54,7 @@ void main()
|
||||
vec3 world_pos;
|
||||
if (hairThicknessRes > 1) {
|
||||
/* Calculate the thickness, thick-time, world-position taken into account the outline. */
|
||||
float outline_width = point_world_to_ndc(center_wpos).w * 1.25 * sizeViewportInv.y *
|
||||
float outline_width = drw_point_world_to_homogenous(center_wpos).w * 1.25 * sizeViewportInv.y *
|
||||
drw_view.wininv[1][1];
|
||||
thickness += outline_width;
|
||||
float thick_time = float(gl_VertexID % hairThicknessRes) / float(hairThicknessRes - 1);
|
||||
@@ -67,10 +68,10 @@ void main()
|
||||
world_pos = center_wpos;
|
||||
}
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
#ifdef USE_GEOM
|
||||
vert.pos = point_world_to_view(world_pos);
|
||||
vert.pos = drw_point_world_to_view(world_pos);
|
||||
#endif
|
||||
|
||||
/* Small bias to always be on top of the geom. */
|
||||
|
||||
@@ -36,7 +36,7 @@ void main()
|
||||
vec3 ray_ori = pos;
|
||||
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);
|
||||
vec4 ndc = drw_point_world_to_homogenous(isect);
|
||||
gl_FragDepth = (ndc.z / ndc.w) * 0.5 + 0.5;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_gpencil_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_pointcloud_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
@@ -39,7 +40,7 @@ void main()
|
||||
{
|
||||
vec3 world_pos = pointcloud_get_pos();
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Small bias to always be on top of the geom. */
|
||||
gl_Position.z -= 1e-3;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
@@ -36,11 +37,11 @@ uint outline_colorid_get()
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
#ifdef USE_GEOM
|
||||
vert.pos = point_world_to_view(world_pos);
|
||||
vert.pos = drw_point_world_to_view(world_pos);
|
||||
#endif
|
||||
|
||||
/* Small bias to always be on top of the geom. */
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
#ifdef GPU_METAL
|
||||
/* Small bias to always be on top of the geom. */
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
bool is_select = (nor.w > 0.0);
|
||||
bool is_hidden = (nor.w < 0.0);
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
/* Add offset in Z to avoid Z-fighting and render selected wires on top. */
|
||||
/* TODO: scale this bias using Z-near and Z-far range. */
|
||||
gl_Position.z -= (is_select ? 2e-4 : 1e-4);
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
uv_interp = mu;
|
||||
|
||||
|
||||
@@ -3,21 +3,20 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
/* Separate actual weight and alerts for independent interpolation */
|
||||
weight_interp = max(vec2(weight, -weight), 0.0);
|
||||
|
||||
/* Saturate the weight to give a hint of the geometry behind the weights. */
|
||||
#ifdef FAKE_SHADING
|
||||
vec3 view_normal = normalize(normal_object_to_view(nor));
|
||||
vec3 view_normal = normalize(drw_normal_object_to_view(nor));
|
||||
color_fac = abs(dot(view_normal, light_dir));
|
||||
color_fac = color_fac * 0.9 + 0.1;
|
||||
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
|
||||
bool is_select = (nor.w > 0.0) && useSelect;
|
||||
bool is_hidden = (nor.w < 0.0) && useSelect;
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
/* Add offset in Z to avoid Z-fighting and render selected wires on top. */
|
||||
/* TODO: scale this bias using Z-near and Z-far range. */
|
||||
gl_Position.z -= (is_select ? 2e-4 : 1e-4);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/* TODO(fclem): Deduplicate wireframe color. */
|
||||
@@ -85,7 +86,7 @@ void main()
|
||||
vec3 ws_P = drw_point_object_to_world(pos);
|
||||
vec3 ws_N = normalize(drw_normal_object_to_world(-nor));
|
||||
|
||||
gl_Position = point_world_to_ndc(ws_P);
|
||||
gl_Position = drw_point_world_to_homogenous(ws_P);
|
||||
|
||||
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -86,7 +86,7 @@ void main()
|
||||
else {
|
||||
world_pos += rotate(shape_pos, part.rotation);
|
||||
}
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
edgeStart = edgePos = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy;
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -15,7 +15,7 @@ void main()
|
||||
|
||||
vec3 world_pos = part_pos;
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
/* World sized points. */
|
||||
gl_PointSize = sizePixel * draw_size * drw_view.winmat[1][1] * sizeViewport.y / gl_Position.w;
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
finalColor = vec4(selection);
|
||||
finalColor.a *= opacity;
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_hair_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
float retrieve_selection()
|
||||
{
|
||||
@@ -30,7 +31,7 @@ void main()
|
||||
thickness,
|
||||
thick_time);
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
mask_weight = 1.0 - (selection_opacity - retrieve_selection() * selection_opacity);
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
faceset_color = mix(vec3(1.0), fset, faceSetsOpacity);
|
||||
mask_color = 1.0 - (msk * maskOpacity);
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
finalColor = attribute_value;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "common_hair_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -21,7 +22,7 @@ void main()
|
||||
time,
|
||||
thickness,
|
||||
thick_time);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
|
||||
if (is_point_domain) {
|
||||
finalColor = texelFetch(color_tx, hair_get_base_id());
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
finalColor = attribute_value;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
#include "common_pointcloud_lib.glsl"
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 world_pos = pointcloud_get_pos();
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
finalColor = pointcloud_get_customdata_vec4(attribute_tx);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
vec4 flag_to_color(uint flag)
|
||||
@@ -100,6 +101,6 @@ void main()
|
||||
vec3 rotated_pos = rot_mat * corners[indices[gl_VertexID % 8]];
|
||||
pos += rotated_pos * cellSize;
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
/* Straight Port from BKE_defvert_weight_to_rgb()
|
||||
@@ -194,6 +195,6 @@ void main()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
gl_Position = drw_point_world_to_homogenous(world_pos);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
void main()
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
#include "select_lib.glsl"
|
||||
|
||||
#if !defined(POINTS) && !defined(CURVES)
|
||||
@@ -88,7 +90,7 @@ void main()
|
||||
{
|
||||
select_id_set(drw_CustomID);
|
||||
|
||||
vec3 wpos = point_object_to_world(pos);
|
||||
vec3 wpos = drw_point_object_to_world(pos);
|
||||
#if defined(POINTS)
|
||||
gl_PointSize = sizeVertex * 2.0;
|
||||
#elif defined(CURVES)
|
||||
@@ -97,7 +99,7 @@ void main()
|
||||
bool no_attr = all(equal(nor, vec3(0)));
|
||||
/* If no attribute is available, use a direction perpendicular
|
||||
* to the view to have full brightness. */
|
||||
vec3 wnor = no_attr ? drw_view.viewinv[1].xyz : normalize(normal_object_to_world(nor));
|
||||
vec3 wnor = no_attr ? drw_view.viewinv[1].xyz : normalize(drw_normal_object_to_world(nor));
|
||||
|
||||
if (isHair) {
|
||||
mat4 obmat = hairDupliMatrix;
|
||||
@@ -111,7 +113,7 @@ void main()
|
||||
float facing = dot(wnor, V);
|
||||
#endif
|
||||
|
||||
gl_Position = point_world_to_ndc(wpos);
|
||||
gl_Position = drw_point_world_to_homogenous(wpos);
|
||||
|
||||
#ifndef CUSTOM_DEPTH_BIAS_CONST
|
||||
/* TODO(fclem): Cleanup after overlay next. */
|
||||
@@ -128,7 +130,7 @@ void main()
|
||||
float flip = sign(facing); /* Flip when not facing the normal (i.e.: back-facing). */
|
||||
float curvature = (1.0 - wd * 0.75); /* Avoid making things worse for curvy areas. */
|
||||
vec3 wofs = wnor * (facing_ratio * curvature * flip);
|
||||
wofs = normal_world_to_view(wofs);
|
||||
wofs = drw_normal_world_to_view(wofs);
|
||||
|
||||
/* Push vertex half a pixel (maximum) in normal direction. */
|
||||
gl_Position.xy += wofs.xy * sizeViewportInv * gl_Position.w;
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "overlay_common_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -11,13 +13,14 @@ void main()
|
||||
select_id = offset + index;
|
||||
#endif
|
||||
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
vec3 view_pos = point_world_to_view(world_pos);
|
||||
gl_Position = point_view_to_ndc(view_pos);
|
||||
vec3 world_pos = drw_point_object_to_world(pos);
|
||||
vec3 view_pos = drw_point_world_to_view(world_pos);
|
||||
gl_Position = drw_point_view_to_homogenous(view_pos);
|
||||
gl_PointSize = sizeVertex;
|
||||
|
||||
/* Offset Z position for retopology selection occlusion. */
|
||||
gl_Position.z += get_homogenous_z_offset(view_pos.z, gl_Position.w, retopologyOffset);
|
||||
gl_Position.z += get_homogenous_z_offset(
|
||||
ProjectionMatrix, view_pos.z, gl_Position.w, retopologyOffset);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup draw
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef GPU_SHADER
|
||||
# include "GPU_shader_shared_utils.hh"
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "common_math_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
#ifndef DRW_GPENCIL_INFO
|
||||
# error Missing additional info draw_gpencil
|
||||
@@ -225,9 +226,9 @@ vec4 gpencil_vertex(vec4 viewport_size,
|
||||
vec3 B = cross(T, ViewMatrixInverse[2].xyz);
|
||||
out_N = normalize(cross(B, T));
|
||||
|
||||
vec4 ndc_adj = point_world_to_ndc(wpos_adj);
|
||||
vec4 ndc1 = point_world_to_ndc(wpos1);
|
||||
vec4 ndc2 = point_world_to_ndc(wpos2);
|
||||
vec4 ndc_adj = drw_point_world_to_homogenous(wpos_adj);
|
||||
vec4 ndc1 = drw_point_world_to_homogenous(wpos1);
|
||||
vec4 ndc2 = drw_point_world_to_homogenous(wpos2);
|
||||
|
||||
out_ndc = (use_curr) ? ndc1 : ndc2;
|
||||
out_P = (use_curr) ? wpos1 : wpos2;
|
||||
@@ -265,7 +266,7 @@ vec4 gpencil_vertex(vec4 viewport_size,
|
||||
x_axis = vec2(1.0, 0.0);
|
||||
}
|
||||
else { /* GP_STROKE_ALIGNMENT_OBJECT */
|
||||
vec4 ndc_x = point_world_to_ndc(wpos1 + ModelMatrix[0].xyz);
|
||||
vec4 ndc_x = drw_point_world_to_homogenous(wpos1 + ModelMatrix[0].xyz);
|
||||
vec2 ss_x = gpencil_project_to_screenspace(ndc_x, viewport_size);
|
||||
x_axis = safe_normalize(ss_x - ss1);
|
||||
}
|
||||
@@ -335,7 +336,7 @@ vec4 gpencil_vertex(vec4 viewport_size,
|
||||
}
|
||||
else {
|
||||
out_P = transform_point(ModelMatrix, pos1.xyz);
|
||||
out_ndc = point_world_to_ndc(out_P);
|
||||
out_ndc = drw_point_world_to_homogenous(out_P);
|
||||
out_uv = uv1.xy;
|
||||
out_thickness.x = 1e18;
|
||||
out_thickness.y = 1e20;
|
||||
@@ -344,10 +345,10 @@ vec4 gpencil_vertex(vec4 viewport_size,
|
||||
out_sspos = vec4(0.0);
|
||||
|
||||
/* Flat normal following camera and object bounds. */
|
||||
vec3 V = cameraVec(ModelMatrix[3].xyz);
|
||||
vec3 N = normal_world_to_object(V);
|
||||
vec3 V = drw_world_incident_vector(ModelMatrix[3].xyz);
|
||||
vec3 N = drw_normal_world_to_object(V);
|
||||
N *= OrcoTexCoFactors[1].xyz;
|
||||
N = normal_object_to_world(N);
|
||||
N = drw_normal_object_to_world(N);
|
||||
out_N = safe_normalize(N);
|
||||
|
||||
/* Decode fill opacity. */
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
/* NOTE: To be used with UNIFORM_RESOURCE_ID and INSTANCED_ATTR as define. */
|
||||
#include "common_view_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#ifdef POINTCLOUD_SHADER
|
||||
# define COMMON_POINTCLOUD_LIB
|
||||
|
||||
@@ -25,7 +26,7 @@ int pointcloud_get_point_id()
|
||||
mat3 pointcloud_get_facing_matrix(vec3 p)
|
||||
{
|
||||
mat3 facing_mat;
|
||||
facing_mat[2] = cameraVec(p);
|
||||
facing_mat[2] = drw_world_incident_vector(p);
|
||||
facing_mat[1] = normalize(cross(ViewMatrixInverse[0].xyz, facing_mat[2]));
|
||||
facing_mat[0] = cross(facing_mat[1], facing_mat[2]);
|
||||
return facing_mat;
|
||||
@@ -36,7 +37,7 @@ void pointcloud_get_pos_and_radius(out vec3 outpos, out float outradius)
|
||||
{
|
||||
int id = pointcloud_get_point_id();
|
||||
vec4 pos_rad = texelFetch(ptcloud_pos_rad_tx, id);
|
||||
outpos = point_object_to_world(pos_rad.xyz);
|
||||
outpos = drw_point_object_to_world(pos_rad.xyz);
|
||||
outradius = dot(abs(to_float3x3(ModelMatrix) * pos_rad.www), vec3(1.0 / 3.0));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,29 +4,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common_view_lib.glsl"
|
||||
|
||||
#if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_SHADER)
|
||||
|
||||
void view_clipping_distances(vec3 wpos)
|
||||
{
|
||||
# ifdef USE_WORLD_CLIP_PLANES
|
||||
vec4 pos_4d = vec4(wpos, 1.0);
|
||||
# ifdef OVERLAY_NEXT
|
||||
gl_ClipDistance[0] = dot(globalsBlock.clip_planes[0], pos_4d);
|
||||
gl_ClipDistance[1] = dot(globalsBlock.clip_planes[1], pos_4d);
|
||||
gl_ClipDistance[2] = dot(globalsBlock.clip_planes[2], pos_4d);
|
||||
gl_ClipDistance[3] = dot(globalsBlock.clip_planes[3], pos_4d);
|
||||
gl_ClipDistance[4] = dot(globalsBlock.clip_planes[4], pos_4d);
|
||||
gl_ClipDistance[5] = dot(globalsBlock.clip_planes[5], pos_4d);
|
||||
# else
|
||||
gl_ClipDistance[0] = dot(drw_clipping_[0], pos_4d);
|
||||
gl_ClipDistance[1] = dot(drw_clipping_[1], pos_4d);
|
||||
gl_ClipDistance[2] = dot(drw_clipping_[2], pos_4d);
|
||||
gl_ClipDistance[3] = dot(drw_clipping_[3], pos_4d);
|
||||
gl_ClipDistance[4] = dot(drw_clipping_[4], pos_4d);
|
||||
gl_ClipDistance[5] = dot(drw_clipping_[5], pos_4d);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,385 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "draw_view_info.hh"
|
||||
|
||||
/* WORKAROUND: to guard against double include in EEVEE. */
|
||||
#ifndef COMMON_VIEW_LIB_GLSL
|
||||
# define COMMON_VIEW_LIB_GLSL
|
||||
|
||||
# ifndef DRW_RESOURCE_CHUNK_LEN
|
||||
# error Missing draw_view additional create info on shader create info
|
||||
# endif
|
||||
|
||||
/* Not supported anymore. TODO(fclem): Add back support. */
|
||||
// #define IS_DEBUG_MOUSE_FRAGMENT (ivec2(gl_FragCoord) == drw_view.mouse_pixel)
|
||||
# define IS_FIRST_INVOCATION (gl_GlobalInvocationID == uvec3(0))
|
||||
|
||||
# define cameraForward ViewMatrixInverse[2].xyz
|
||||
# define cameraPos ViewMatrixInverse[3].xyz
|
||||
vec3 cameraVec(vec3 P)
|
||||
{
|
||||
return ((ProjectionMatrix[3][3] == 0.0) ? normalize(cameraPos - P) : cameraForward);
|
||||
}
|
||||
# define viewCameraVec(vP) \
|
||||
((ProjectionMatrix[3][3] == 0.0) ? normalize(-vP) : vec3(0.0, 0.0, 1.0))
|
||||
|
||||
# ifdef COMMON_GLOBALS_LIB
|
||||
/* TODO move to overlay engine. */
|
||||
float mul_project_m4_v3_zfac(vec3 co)
|
||||
{
|
||||
vec3 vP = (ViewMatrix * vec4(co, 1.0)).xyz;
|
||||
return pixelFac * ((ProjectionMatrix[0][3] * vP.x) + (ProjectionMatrix[1][3] * vP.y) +
|
||||
(ProjectionMatrix[2][3] * vP.z) + ProjectionMatrix[3][3]);
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Not the right place but need to be common to all overlay's.
|
||||
* TODO: Split to an overlay lib. */
|
||||
mat4 extract_matrix_packed_data(mat4 mat, out vec4 dataA, out vec4 dataB)
|
||||
{
|
||||
const float div = 1.0 / 255.0;
|
||||
int a = int(mat[0][3]);
|
||||
int b = int(mat[1][3]);
|
||||
int c = int(mat[2][3]);
|
||||
int d = int(mat[3][3]);
|
||||
dataA = vec4(a & 0xFF, a >> 8, b & 0xFF, b >> 8) * div;
|
||||
dataB = vec4(c & 0xFF, c >> 8, d & 0xFF, d >> 8) * div;
|
||||
mat[0][3] = mat[1][3] = mat[2][3] = 0.0;
|
||||
mat[3][3] = 1.0;
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* Same here, Not the right place but need to be common to all overlay's.
|
||||
* TODO: Split to an overlay lib. */
|
||||
/* edge_start and edge_pos needs to be in the range [0..sizeViewport]. */
|
||||
vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 edge_pos)
|
||||
{
|
||||
vec2 edge = edge_start - edge_pos;
|
||||
float len = length(edge);
|
||||
if (len > 0.0) {
|
||||
edge /= len;
|
||||
vec2 perp = vec2(-edge.y, edge.x);
|
||||
float dist = dot(perp, frag_co - edge_start);
|
||||
/* Add 0.1 to differentiate with cleared pixels. */
|
||||
return vec4(perp * 0.5 + 0.5, dist * 0.25 + 0.5 + 0.1, 1.0);
|
||||
}
|
||||
else {
|
||||
/* Default line if the origin is perfectly aligned with a pixel. */
|
||||
return vec4(1.0, 0.0, 0.5 + 0.1, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
uniform int drw_resourceChunk;
|
||||
# endif /* !USE_GPU_SHADER_CREATE_INFO */
|
||||
|
||||
# ifdef GPU_VERTEX_SHADER
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
|
||||
/* clang-format off */
|
||||
# if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTR) || defined(DRW_LEGACY_MODEL_MATRIX) || defined(GPU_DEPRECATED_AMD_DRIVER)
|
||||
/* clang-format on */
|
||||
/* When drawing instances of an object at the same position. */
|
||||
# define instanceId 0
|
||||
# else
|
||||
# define instanceId gl_InstanceID
|
||||
# endif
|
||||
|
||||
# if defined(UNIFORM_RESOURCE_ID)
|
||||
/* This is in the case we want to do a special instance drawcall for one object but still want to
|
||||
* have the right resourceId and all the correct UBO datas. */
|
||||
uniform int drw_ResourceID;
|
||||
# define resource_id drw_ResourceID
|
||||
# else
|
||||
# define resource_id (gpu_BaseInstance + instanceId)
|
||||
# endif
|
||||
|
||||
/* Use this to declare and pass the value if
|
||||
* the fragment shader uses the resource_id. */
|
||||
# if defined(EEVEE_GENERATED_INTERFACE)
|
||||
# define RESOURCE_ID_VARYING
|
||||
# define PASS_RESOURCE_ID resourceIDFrag = resource_id;
|
||||
# elif defined(USE_GEOMETRY_SHADER)
|
||||
# define RESOURCE_ID_VARYING flat out int resourceIDGeom;
|
||||
# define PASS_RESOURCE_ID resourceIDGeom = resource_id;
|
||||
# else
|
||||
# define RESOURCE_ID_VARYING flat out int resourceIDFrag;
|
||||
# define PASS_RESOURCE_ID resourceIDFrag = resource_id;
|
||||
# endif
|
||||
|
||||
# endif /* USE_GPU_SHADER_CREATE_INFO */
|
||||
|
||||
# endif /* GPU_VERTEX_SHADER */
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifdef USE_GPU_SHADER_CREATE_INFO
|
||||
/* TODO(fclem): Rename PASS_RESOURCE_ID to DRW_RESOURCE_ID_VARYING_SET */
|
||||
# if defined(UNIFORM_RESOURCE_ID)
|
||||
# define resource_id drw_ResourceID
|
||||
# define PASS_RESOURCE_ID
|
||||
|
||||
# elif defined(GPU_VERTEX_SHADER)
|
||||
# if defined(UNIFORM_RESOURCE_ID_NEW)
|
||||
# define resource_id (drw_ResourceID >> DRW_VIEW_SHIFT)
|
||||
# else
|
||||
# define resource_id gpu_InstanceIndex
|
||||
# endif
|
||||
# define PASS_RESOURCE_ID drw_ResourceID_iface.resource_index = resource_id;
|
||||
|
||||
# elif defined(GPU_GEOMETRY_SHADER)
|
||||
# define resource_id drw_ResourceID_iface_in[0].resource_index
|
||||
# define PASS_RESOURCE_ID drw_ResourceID_iface_out.resource_index = resource_id;
|
||||
|
||||
# elif defined(GPU_FRAGMENT_SHADER)
|
||||
# define resource_id drw_ResourceID_iface.resource_index
|
||||
# endif
|
||||
|
||||
/* TODO(fclem): Remove. */
|
||||
# define RESOURCE_ID_VARYING
|
||||
|
||||
# else
|
||||
/* If used in a fragment / geometry shader, we pass
|
||||
* resource_id as varying. */
|
||||
# ifdef GPU_GEOMETRY_SHADER
|
||||
/* TODO(fclem): Remove. This is getting ridiculous. */
|
||||
# if !defined(EEVEE_GENERATED_INTERFACE)
|
||||
# define RESOURCE_ID_VARYING \
|
||||
flat out int resourceIDFrag; \
|
||||
flat in int resourceIDGeom[];
|
||||
# else
|
||||
# define RESOURCE_ID_VARYING
|
||||
# endif
|
||||
|
||||
# define resource_id resourceIDGeom
|
||||
# define PASS_RESOURCE_ID resourceIDFrag = resource_id[0];
|
||||
# endif
|
||||
|
||||
# if defined(GPU_FRAGMENT_SHADER)
|
||||
# if !defined(EEVEE_GENERATED_INTERFACE)
|
||||
flat in int resourceIDFrag;
|
||||
# endif
|
||||
# define resource_id resourceIDFrag
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Breaking this across multiple lines causes issues for some older GLSL compilers. */
|
||||
/* clang-format off */
|
||||
#if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && (!defined(OS_MAC) || defined(GPU_METAL)) && !defined(INSTANCED_ATTR) && !defined(DRW_LEGACY_MODEL_MATRIX)
|
||||
/* clang-format on */
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifndef DRW_SHADER_SHARED_H
|
||||
|
||||
struct ObjectMatrices {
|
||||
mat4 model;
|
||||
mat4 model_inverse;
|
||||
};
|
||||
# endif /* !DRW_SHADER_SHARED_H */
|
||||
|
||||
# ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
layout(std140) uniform modelBlock
|
||||
{
|
||||
ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN];
|
||||
};
|
||||
|
||||
# define ModelMatrix (drw_matrices[resource_id].model)
|
||||
# define ModelMatrixInverse (drw_matrices[resource_id].model_inverse)
|
||||
# endif /* USE_GPU_SHADER_CREATE_INFO */
|
||||
|
||||
# else /* GPU_INTEL */
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
/* Intel GPU seems to suffer performance impact when the model matrix is in UBO storage.
|
||||
* So for now we just force using the legacy path. */
|
||||
/* Note that this is also a workaround of a problem on OSX (AMD or NVIDIA)
|
||||
* and older AMD driver on windows. */
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 ModelMatrixInverse;
|
||||
# endif /* !USE_GPU_SHADER_CREATE_INFO */
|
||||
|
||||
# endif
|
||||
|
||||
/* Temporary until we fully make the switch. */
|
||||
# ifndef USE_GPU_SHADER_CREATE_INFO
|
||||
# define resource_handle (drw_resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)
|
||||
# endif
|
||||
|
||||
/** Transform shortcuts. */
|
||||
/* Rule of thumb: Try to reuse world positions and normals because converting through view-space
|
||||
* will always be decomposed in at least 2 matrix operation. */
|
||||
|
||||
/**
|
||||
* Some clarification:
|
||||
* Usually Normal matrix is transpose(inverse(ViewMatrix * ModelMatrix))
|
||||
*
|
||||
* But since it is slow to multiply matrices we decompose it. Decomposing
|
||||
* inversion and transposition both invert the product order leaving us with
|
||||
* the same original order:
|
||||
* transpose(ViewMatrixInverse) * transpose(ModelMatrixInverse)
|
||||
*
|
||||
* Knowing that the view matrix is orthogonal, the transpose is also the inverse.
|
||||
* NOTE: This is only valid because we are only using the mat3 of the ViewMatrixInverse.
|
||||
* ViewMatrix * transpose(ModelMatrixInverse)
|
||||
*/
|
||||
# define NormalMatrix transpose(to_float3x3(ModelMatrixInverse))
|
||||
# define NormalMatrixInverse transpose(to_float3x3(ModelMatrix))
|
||||
|
||||
# define normal_object_to_view(n) (to_float3x3(ViewMatrix) * (NormalMatrix * n))
|
||||
# define normal_object_to_world(n) (NormalMatrix * n)
|
||||
# define normal_world_to_object(n) (NormalMatrixInverse * n)
|
||||
# define normal_world_to_view(n) (to_float3x3(ViewMatrix) * n)
|
||||
# define normal_view_to_world(n) (to_float3x3(ViewMatrixInverse) * n)
|
||||
|
||||
# define point_object_to_ndc(p) \
|
||||
(ProjectionMatrix * (ViewMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0)))
|
||||
# define point_object_to_view(p) ((ViewMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0)).xyz)
|
||||
# define point_object_to_world(p) ((ModelMatrix * vec4(p, 1.0)).xyz)
|
||||
# define point_view_to_object(p) ((ModelMatrixInverse * (ViewMatrixInverse * vec4(p, 1.0))).xyz)
|
||||
# define point_world_to_object(p) ((ModelMatrixInverse * vec4(p, 1.0)).xyz)
|
||||
|
||||
vec4 point_view_to_ndc(vec3 p)
|
||||
{
|
||||
return ProjectionMatrix * vec4(p, 1.0);
|
||||
}
|
||||
|
||||
vec3 point_view_to_world(vec3 p)
|
||||
{
|
||||
return (ViewMatrixInverse * vec4(p, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec4 point_world_to_ndc(vec3 p)
|
||||
{
|
||||
return ProjectionMatrix * (ViewMatrix * vec4(p, 1.0));
|
||||
}
|
||||
|
||||
vec3 point_world_to_view(vec3 p)
|
||||
{
|
||||
return (ViewMatrix * vec4(p, 1.0)).xyz;
|
||||
}
|
||||
|
||||
/* View-space Z is used to adjust for perspective projection.
|
||||
* Homogenous W is used to convert from NDC to homogenous space.
|
||||
* Offset is in view-space, so positive values are closer to the camera. */
|
||||
float get_homogenous_z_offset(float vs_z, float hs_w, float vs_offset)
|
||||
{
|
||||
if (vs_offset == 0.0) {
|
||||
/* Don't calculate homogenous offset if view-space offset is zero. */
|
||||
return 0.0;
|
||||
}
|
||||
else if (ProjectionMatrix[3][3] == 0.0) {
|
||||
/* Clamp offset to half of Z to avoid floating point precision errors. */
|
||||
vs_offset = min(vs_offset, vs_z * -0.5);
|
||||
/* From "Projection Matrix Tricks" by Eric Lengyel:
|
||||
* http://www.terathon.com/gdc07_lengyel.pdf (p. 24 Depth Modification) */
|
||||
return ProjectionMatrix[3][2] * (vs_offset / (vs_z * (vs_z + vs_offset))) * hs_w;
|
||||
}
|
||||
else {
|
||||
return ProjectionMatrix[2][2] * vs_offset * hs_w;
|
||||
}
|
||||
}
|
||||
|
||||
/* Due to some shader compiler bug, we somewhat need to access gl_VertexID
|
||||
* to make vertex shaders work. even if it's actually dead code. */
|
||||
# if defined(GPU_INTEL) && defined(GPU_OPENGL)
|
||||
# define GPU_INTEL_VERTEX_SHADER_WORKAROUND gl_Position.x = float(gl_VertexID);
|
||||
# else
|
||||
# define GPU_INTEL_VERTEX_SHADER_WORKAROUND
|
||||
# endif
|
||||
|
||||
# define DRW_BASE_SELECTED (1 << 1)
|
||||
# define DRW_BASE_FROM_DUPLI (1 << 2)
|
||||
# define DRW_BASE_FROM_SET (1 << 3)
|
||||
# define DRW_BASE_ACTIVE (1 << 4)
|
||||
|
||||
/* Wire Color Types, matching eV3DShadingColorType. */
|
||||
# define V3D_SHADING_SINGLE_COLOR 2
|
||||
# define V3D_SHADING_OBJECT_COLOR 4
|
||||
# define V3D_SHADING_RANDOM_COLOR 1
|
||||
|
||||
/* ---- Opengl Depth conversion ---- */
|
||||
|
||||
float linear_depth(bool is_persp, float z, float zf, float zn)
|
||||
{
|
||||
if (is_persp) {
|
||||
return (zn * zf) / (z * (zn - zf) + zf);
|
||||
}
|
||||
else {
|
||||
return (z * 2.0 - 1.0) * zf;
|
||||
}
|
||||
}
|
||||
|
||||
float buffer_depth(bool is_persp, float z, float zf, float zn)
|
||||
{
|
||||
if (is_persp) {
|
||||
return (zf * (zn - z)) / (z * (zn - zf));
|
||||
}
|
||||
else {
|
||||
return (z / (zf * 2.0)) + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
float get_view_z_from_depth(float depth)
|
||||
{
|
||||
float d = 2.0 * depth - 1.0;
|
||||
if (ProjectionMatrix[3][3] == 0.0) {
|
||||
d = -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]);
|
||||
}
|
||||
else {
|
||||
d = (d - ProjectionMatrix[3][2]) / ProjectionMatrix[2][2];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
float get_depth_from_view_z(float z)
|
||||
{
|
||||
float d;
|
||||
if (ProjectionMatrix[3][3] == 0.0) {
|
||||
d = (-ProjectionMatrix[3][2] / z) - ProjectionMatrix[2][2];
|
||||
}
|
||||
else {
|
||||
d = ProjectionMatrix[2][2] * z + ProjectionMatrix[3][2];
|
||||
}
|
||||
return d * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec2 get_uvs_from_view(vec3 view)
|
||||
{
|
||||
vec4 ndc = ProjectionMatrix * vec4(view, 1.0);
|
||||
return (ndc.xy / ndc.w) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
|
||||
{
|
||||
vec3 ndc = vec3(uvcoords, depth) * 2.0 - 1.0;
|
||||
vec4 p = ProjectionMatrixInverse * vec4(ndc, 1.0);
|
||||
return p.xyz / p.w;
|
||||
}
|
||||
|
||||
vec3 get_world_space_from_depth(vec2 uvcoords, float depth)
|
||||
{
|
||||
return (ViewMatrixInverse * vec4(get_view_space_from_depth(uvcoords, depth), 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 get_view_vector_from_screen_uv(vec2 uvcoords)
|
||||
{
|
||||
if (ProjectionMatrix[3][3] == 0.0) {
|
||||
vec2 ndc = vec2(uvcoords * 2.0 - 1.0);
|
||||
/* This is the manual inversion of the ProjectionMatrix. */
|
||||
vec3 vV = vec3((-ndc - ProjectionMatrix[2].xy) /
|
||||
vec2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]),
|
||||
-ProjectionMatrix[2][2] - ProjectionMatrix[3][2]);
|
||||
return normalize(vV);
|
||||
}
|
||||
/* Orthographic case. */
|
||||
return vec3(0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
#endif /* COMMON_VIEW_LIB_GLSL */
|
||||
@@ -201,17 +201,6 @@ GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Draw Globals
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_CREATE_INFO(draw_globals)
|
||||
TYPEDEF_SOURCE("draw_common_shader_shared.hh")
|
||||
UNIFORM_BUF_FREQ(OVERLAY_GLOBALS_SLOT, GlobalsUboStorage, globalsBlock, PASS)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Draw Manager usage
|
||||
* \{ */
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
#include "overlay_antialiasing_info.hh"
|
||||
#include "overlay_armature_info.hh"
|
||||
#include "overlay_background_info.hh"
|
||||
#include "overlay_common_info.hh"
|
||||
#include "overlay_edit_mode_info.hh"
|
||||
#include "overlay_extra_info.hh"
|
||||
#include "overlay_facing_info.hh"
|
||||
|
||||
Reference in New Issue
Block a user