2023-08-24 10:54:59 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2019-2023 Blender Authors
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-12-02 01:40:58 +01:00
|
|
|
|
2025-09-25 10:57:02 +02:00
|
|
|
#include "infos/overlay_extra_infos.hh"
|
2025-02-24 16:17:18 +01:00
|
|
|
|
|
|
|
|
VERTEX_SHADER_CREATE_INFO(overlay_image_base)
|
2025-02-25 23:05:03 +01:00
|
|
|
VERTEX_SHADER_CREATE_INFO(draw_modelmat)
|
2025-02-24 16:17:18 +01:00
|
|
|
|
2025-01-23 18:06:22 +01:00
|
|
|
#include "draw_model_lib.glsl"
|
2025-02-19 17:46:04 +01:00
|
|
|
#include "draw_view_clipping_lib.glsl"
|
2025-01-23 18:06:22 +01:00
|
|
|
#include "draw_view_lib.glsl"
|
2024-10-04 15:48:22 +02:00
|
|
|
#include "select_lib.glsl"
|
2019-12-02 01:40:58 +01:00
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2025-03-04 00:20:52 +01:00
|
|
|
select_id_set(drw_custom_id());
|
2025-04-14 13:46:41 +02:00
|
|
|
float3 world_pos = drw_point_object_to_world(pos);
|
2025-04-24 12:50:45 +02:00
|
|
|
if (is_camera_background) {
|
2023-02-12 14:37:16 +11:00
|
|
|
/* Model matrix converts to view position to avoid jittering (see #91398). */
|
2024-11-18 16:23:30 +01:00
|
|
|
#ifdef DEPTH_BIAS
|
2025-04-14 13:46:41 +02:00
|
|
|
gl_Position = depth_bias_winmat * float4(world_pos, 1.0f);
|
2024-11-18 16:23:30 +01:00
|
|
|
#else
|
2025-01-23 18:06:22 +01:00
|
|
|
gl_Position = drw_point_view_to_homogenous(world_pos);
|
2024-11-18 16:23:30 +01:00
|
|
|
#endif
|
2022-05-01 16:18:26 +02:00
|
|
|
/* Camera background images are not really part of the 3D space.
|
|
|
|
|
* It makes no sense to apply clipping on them. */
|
|
|
|
|
view_clipping_distances_bypass();
|
2021-10-14 11:27:30 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2024-11-18 16:23:30 +01:00
|
|
|
#ifdef DEPTH_BIAS
|
2025-04-14 13:46:41 +02:00
|
|
|
gl_Position = depth_bias_winmat * (drw_view().viewmat * float4(world_pos, 1.0f));
|
2024-11-18 16:23:30 +01:00
|
|
|
#else
|
2025-01-23 18:06:22 +01:00
|
|
|
gl_Position = drw_point_world_to_homogenous(world_pos);
|
2024-11-18 16:23:30 +01:00
|
|
|
#endif
|
2022-05-01 16:18:26 +02:00
|
|
|
view_clipping_distances(world_pos);
|
2021-10-14 11:27:30 +02:00
|
|
|
}
|
2019-12-02 01:40:58 +01:00
|
|
|
|
2025-04-24 12:50:45 +02:00
|
|
|
if (depth_set) {
|
2019-12-02 01:40:58 +01:00
|
|
|
/* Result in a position at 1.0 (far plane). Small epsilon to avoid precision issue.
|
|
|
|
|
* This mimics the effect of infinite projection matrix
|
|
|
|
|
* (see http://www.terathon.com/gdc07_lengyel.pdf). */
|
2025-04-11 18:28:45 +02:00
|
|
|
gl_Position.z = gl_Position.w - 2.4e-7f;
|
2022-05-01 16:18:26 +02:00
|
|
|
view_clipping_distances_bypass();
|
2019-12-02 01:40:58 +01:00
|
|
|
}
|
|
|
|
|
|
2025-04-11 18:28:45 +02:00
|
|
|
uvs = pos.xy * 0.5f + 0.5f;
|
2019-12-02 01:40:58 +01:00
|
|
|
}
|