DRW: Remove Basic engine
All remaining shaders were moved to overlay. The basic engine is not used anymore since all selection and depth picking happens inside overlay engine.
This commit is contained in:
@@ -102,8 +102,6 @@ set(SRC
|
||||
intern/draw_view_c.cc
|
||||
intern/draw_view_data.cc
|
||||
intern/draw_volume.cc
|
||||
engines/basic/basic_engine.cc
|
||||
engines/basic/basic_shader.cc
|
||||
engines/compositor/compositor_engine.cc
|
||||
engines/image/image_engine.cc
|
||||
engines/image/image_drawing_mode.cc
|
||||
@@ -207,8 +205,6 @@ set(SRC
|
||||
intern/draw_view_c.hh
|
||||
intern/draw_view_data.hh
|
||||
intern/mesh_extractors/extract_mesh.hh
|
||||
engines/basic/basic_engine.h
|
||||
engines/basic/basic_private.h
|
||||
engines/compositor/compositor_engine.h
|
||||
engines/eevee_next/eevee_ambient_occlusion.hh
|
||||
engines/eevee_next/eevee_camera.hh
|
||||
@@ -614,12 +610,6 @@ set(GLSL_SRC
|
||||
|
||||
engines/select/select_shader_shared.hh
|
||||
|
||||
engines/basic/shaders/basic_conservative_depth_geom.glsl
|
||||
engines/basic/shaders/basic_depth_vert.glsl
|
||||
engines/basic/shaders/basic_depth_curves_vert.glsl
|
||||
engines/basic/shaders/basic_depth_pointcloud_vert.glsl
|
||||
engines/basic/shaders/basic_depth_frag.glsl
|
||||
|
||||
engines/overlay/shaders/overlay_antialiasing_frag.glsl
|
||||
engines/overlay/shaders/overlay_armature_dof_solid_frag.glsl
|
||||
engines/overlay/shaders/overlay_armature_dof_vert.glsl
|
||||
@@ -645,10 +635,12 @@ set(GLSL_SRC
|
||||
engines/overlay/shaders/overlay_background_frag.glsl
|
||||
engines/overlay/shaders/overlay_clipbound_vert.glsl
|
||||
engines/overlay/shaders/overlay_common_lib.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_curves_vert.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_frag.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_gpencil_frag.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_gpencil_vert.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_mesh_conservative_vert.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_pointcloud_vert.glsl
|
||||
engines/overlay/shaders/overlay_depth_only_vert.glsl
|
||||
engines/overlay/shaders/overlay_edit_curve_handle_geom.glsl
|
||||
engines/overlay/shaders/overlay_edit_curve_handle_next_vert.glsl
|
||||
|
||||
@@ -126,7 +126,6 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph,
|
||||
View3D *v3d,
|
||||
GPUViewport *viewport,
|
||||
const bool use_gpencil,
|
||||
const bool use_basic,
|
||||
const bool use_overlay,
|
||||
const bool use_only_selected);
|
||||
/**
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2016 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup draw_engine
|
||||
*
|
||||
* Simple engine for drawing color and/or depth.
|
||||
* When we only need simple flat shaders.
|
||||
*/
|
||||
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_object.hh"
|
||||
#include "BKE_object_types.hh"
|
||||
#include "BKE_paint.hh"
|
||||
#include "BKE_paint_bvh.hh"
|
||||
#include "BKE_particle.h"
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
|
||||
#include "DNA_particle_types.h"
|
||||
|
||||
#include "GPU_shader.hh"
|
||||
|
||||
#include "basic_engine.h"
|
||||
#include "basic_private.h"
|
||||
|
||||
#define BASIC_ENGINE "BLENDER_BASIC"
|
||||
|
||||
/* *********** LISTS *********** */
|
||||
|
||||
/* GPUViewport.storage
|
||||
* Is freed every time the viewport engine changes. */
|
||||
struct BASIC_StorageList {
|
||||
struct BASIC_PrivateData *g_data;
|
||||
};
|
||||
|
||||
struct BASIC_PassList {
|
||||
DRWPass *depth_pass[2];
|
||||
DRWPass *depth_pass_pointcloud[2];
|
||||
DRWPass *depth_pass_cull[2];
|
||||
};
|
||||
|
||||
struct BASIC_Data {
|
||||
void *engine_type;
|
||||
DRWViewportEmptyList *fbl;
|
||||
DRWViewportEmptyList *txl;
|
||||
BASIC_PassList *psl;
|
||||
BASIC_StorageList *stl;
|
||||
};
|
||||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
struct BASIC_PrivateData {
|
||||
DRWShadingGroup *depth_shgrp[2];
|
||||
DRWShadingGroup *depth_shgrp_cull[2];
|
||||
DRWShadingGroup *depth_hair_shgrp[2];
|
||||
DRWShadingGroup *depth_curves_shgrp[2];
|
||||
DRWShadingGroup *depth_pointcloud_shgrp[2];
|
||||
bool use_material_slot_selection;
|
||||
}; /* Transient data */
|
||||
|
||||
static void basic_cache_init(void *vedata)
|
||||
{
|
||||
BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl;
|
||||
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
||||
DRWShadingGroup *grp;
|
||||
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = static_cast<BASIC_PrivateData *>(MEM_callocN(sizeof(*stl->g_data), __func__));
|
||||
}
|
||||
|
||||
stl->g_data->use_material_slot_selection = DRW_state_is_material_select();
|
||||
|
||||
/* Twice for normal and in front objects. */
|
||||
for (int i = 0; i < 2; i++) {
|
||||
DRWState clip_state = DRWState(
|
||||
(draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? DRW_STATE_CLIP_PLANES : DRW_STATE_NO_DRAW);
|
||||
DRWState infront_state = DRWState(
|
||||
(DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : DRW_STATE_NO_DRAW);
|
||||
DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
|
||||
|
||||
GPUShader *sh = DRW_state_is_select() ?
|
||||
BASIC_shaders_depth_conservative_sh_get(draw_ctx->sh_cfg) :
|
||||
BASIC_shaders_depth_sh_get(draw_ctx->sh_cfg);
|
||||
|
||||
DRW_PASS_CREATE(psl->depth_pass[i], state | clip_state | infront_state);
|
||||
stl->g_data->depth_shgrp[i] = grp = DRW_shgroup_create(sh, psl->depth_pass[i]);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
|
||||
sh = DRW_state_is_select() ?
|
||||
BASIC_shaders_pointcloud_depth_conservative_sh_get(draw_ctx->sh_cfg) :
|
||||
BASIC_shaders_pointcloud_depth_sh_get(draw_ctx->sh_cfg);
|
||||
DRW_PASS_CREATE(psl->depth_pass_pointcloud[i], state | clip_state | infront_state);
|
||||
stl->g_data->depth_pointcloud_shgrp[i] = grp = DRW_shgroup_create(
|
||||
sh, psl->depth_pass_pointcloud[i]);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
|
||||
stl->g_data->depth_hair_shgrp[i] = grp = DRW_shgroup_create(
|
||||
BASIC_shaders_depth_sh_get(draw_ctx->sh_cfg), psl->depth_pass[i]);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
|
||||
stl->g_data->depth_curves_shgrp[i] = grp = DRW_shgroup_create(
|
||||
BASIC_shaders_curves_depth_sh_get(draw_ctx->sh_cfg), psl->depth_pass[i]);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
|
||||
sh = DRW_state_is_select() ? BASIC_shaders_depth_conservative_sh_get(draw_ctx->sh_cfg) :
|
||||
BASIC_shaders_depth_sh_get(draw_ctx->sh_cfg);
|
||||
state |= DRW_STATE_CULL_BACK;
|
||||
DRW_PASS_CREATE(psl->depth_pass_cull[i], state | clip_state | infront_state);
|
||||
stl->g_data->depth_shgrp_cull[i] = grp = DRW_shgroup_create(sh, psl->depth_pass_cull[i]);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO(fclem): DRW_cache_object_surface_material_get needs a refactor to allow passing nullptr
|
||||
* instead of gpumat_array. Avoiding all this boilerplate code. */
|
||||
static blender::gpu::Batch **basic_object_surface_material_get(Object *ob)
|
||||
{
|
||||
const int materials_len = DRW_cache_object_material_count_get(ob);
|
||||
GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
|
||||
memset(gpumat_array, 0, sizeof(*gpumat_array) * materials_len);
|
||||
|
||||
return DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len);
|
||||
}
|
||||
|
||||
static void basic_cache_populate_particles(void *vedata, Object *ob)
|
||||
{
|
||||
const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
|
||||
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
||||
for (ParticleSystem *psys = static_cast<ParticleSystem *>(ob->particlesystem.first);
|
||||
psys != nullptr;
|
||||
psys = psys->next)
|
||||
{
|
||||
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
|
||||
continue;
|
||||
}
|
||||
ParticleSettings *part = psys->part;
|
||||
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
||||
if (draw_as == PART_DRAW_PATH) {
|
||||
blender::gpu::Batch *hairs = DRW_cache_particles_get_hair(ob, psys, nullptr);
|
||||
if (stl->g_data->use_material_slot_selection) {
|
||||
const short material_slot = part->omat;
|
||||
DRW_select_load_id(ob->runtime->select_id | (material_slot << 16));
|
||||
}
|
||||
DRW_shgroup_call(stl->g_data->depth_hair_shgrp[do_in_front], hairs, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void basic_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
using namespace blender::draw;
|
||||
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
||||
|
||||
/* TODO(fclem): fix selection of smoke domains. */
|
||||
|
||||
if (!DRW_object_is_renderable(ob) || (ob->dt < OB_SOLID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
if (ob != draw_ctx->object_edit) {
|
||||
basic_cache_populate_particles(vedata, ob);
|
||||
}
|
||||
|
||||
const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
|
||||
if (ob->type == OB_CURVES) {
|
||||
DRW_shgroup_curves_create_sub(ob, stl->g_data->depth_curves_shgrp[do_in_front], nullptr);
|
||||
}
|
||||
|
||||
if (ob->type == OB_POINTCLOUD) {
|
||||
DRW_shgroup_pointcloud_create_sub(
|
||||
ob, stl->g_data->depth_pointcloud_shgrp[do_in_front], nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make flat object selectable in ortho view if wireframe is enabled. */
|
||||
if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
|
||||
(draw_ctx->v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE))
|
||||
{
|
||||
int flat_axis = 0;
|
||||
bool is_flat_object_viewed_from_side = ((draw_ctx->rv3d->persp == RV3D_ORTHO) &&
|
||||
DRW_object_is_flat(ob, &flat_axis) &&
|
||||
DRW_object_axis_orthogonal_to_view(ob, flat_axis));
|
||||
|
||||
if (is_flat_object_viewed_from_side) {
|
||||
/* Avoid losing flat objects when in ortho views (see #56549) */
|
||||
blender::gpu::Batch *geom = DRW_cache_object_all_edges_get(ob);
|
||||
if (geom) {
|
||||
DRW_shgroup_call(stl->g_data->depth_shgrp[do_in_front], geom, ob);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
|
||||
!DRW_state_is_image_render();
|
||||
const bool do_cull = (draw_ctx->v3d &&
|
||||
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
|
||||
|
||||
DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] :
|
||||
stl->g_data->depth_shgrp[do_in_front];
|
||||
|
||||
if (use_sculpt_pbvh) {
|
||||
DRW_shgroup_call_sculpt(shgrp, ob, false, false, false, false, false);
|
||||
}
|
||||
else {
|
||||
if (stl->g_data->use_material_slot_selection && BKE_object_supports_material_slots(ob)) {
|
||||
blender::gpu::Batch **geoms = basic_object_surface_material_get(ob);
|
||||
if (geoms) {
|
||||
const int materials_len = DRW_cache_object_material_count_get(ob);
|
||||
for (int i = 0; i < materials_len; i++) {
|
||||
if (geoms[i] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
const short material_slot_select_id = i + 1;
|
||||
DRW_select_load_id(ob->runtime->select_id | (material_slot_select_id << 16));
|
||||
DRW_shgroup_call(shgrp, geoms[i], ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
blender::gpu::Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
DRW_shgroup_call(shgrp, geom, ob);
|
||||
}
|
||||
}
|
||||
|
||||
if (G.debug_value == 889 && ob->sculpt && blender::bke::object::pbvh_get(*ob)) {
|
||||
int debug_node_nr = 0;
|
||||
DRW_debug_modelmat(ob->object_to_world().ptr());
|
||||
BKE_pbvh_draw_debug_cb(
|
||||
*blender::bke::object::pbvh_get(*ob), DRW_sculpt_debug_cb, &debug_node_nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void basic_cache_finish(void *vedata)
|
||||
{
|
||||
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
||||
|
||||
UNUSED_VARS(stl);
|
||||
}
|
||||
|
||||
static void basic_draw_scene(void *vedata)
|
||||
{
|
||||
BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl;
|
||||
|
||||
DRW_draw_pass(psl->depth_pass[0]);
|
||||
DRW_draw_pass(psl->depth_pass_pointcloud[0]);
|
||||
DRW_draw_pass(psl->depth_pass_cull[0]);
|
||||
DRW_draw_pass(psl->depth_pass[1]);
|
||||
DRW_draw_pass(psl->depth_pass_pointcloud[1]);
|
||||
DRW_draw_pass(psl->depth_pass_cull[1]);
|
||||
}
|
||||
|
||||
static void basic_engine_free()
|
||||
{
|
||||
BASIC_shaders_free();
|
||||
}
|
||||
|
||||
static const DrawEngineDataSize basic_data_size = DRW_VIEWPORT_DATA_SIZE(BASIC_Data);
|
||||
|
||||
DrawEngineType draw_engine_basic_type = {
|
||||
/*next*/ nullptr,
|
||||
/*prev*/ nullptr,
|
||||
/*idname*/ N_("Basic"),
|
||||
/*vedata_size*/ &basic_data_size,
|
||||
/*engine_init*/ nullptr,
|
||||
/*engine_free*/ &basic_engine_free,
|
||||
/*instance_free*/ nullptr,
|
||||
/*cache_init*/ &basic_cache_init,
|
||||
/*cache_populate*/ &basic_cache_populate,
|
||||
/*cache_finish*/ &basic_cache_finish,
|
||||
/*draw_scene*/ &basic_draw_scene,
|
||||
/*view_update*/ nullptr,
|
||||
/*id_update*/ nullptr,
|
||||
/*render_to_image*/ nullptr,
|
||||
/*store_metadata*/ nullptr,
|
||||
};
|
||||
|
||||
#undef BASIC_ENGINE
|
||||
@@ -1,19 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2016 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup draw_engine
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern DrawEngineType draw_engine_basic_type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2020 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup draw_engine
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
GPUShader *BASIC_shaders_depth_sh_get(eGPUShaderConfig config);
|
||||
GPUShader *BASIC_shaders_pointcloud_depth_sh_get(eGPUShaderConfig config);
|
||||
GPUShader *BASIC_shaders_curves_depth_sh_get(eGPUShaderConfig config);
|
||||
GPUShader *BASIC_shaders_depth_conservative_sh_get(eGPUShaderConfig config);
|
||||
GPUShader *BASIC_shaders_pointcloud_depth_conservative_sh_get(eGPUShaderConfig config);
|
||||
void BASIC_shaders_free(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,98 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2019 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup draw_engine
|
||||
*/
|
||||
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "GPU_shader.hh"
|
||||
|
||||
#include "basic_private.h"
|
||||
|
||||
extern "C" char datatoc_basic_depth_frag_glsl[];
|
||||
extern "C" char datatoc_basic_depth_vert_glsl[];
|
||||
extern "C" char datatoc_basic_conservative_depth_geom_glsl[];
|
||||
|
||||
extern "C" char datatoc_common_view_lib_glsl[];
|
||||
extern "C" char datatoc_common_pointcloud_lib_glsl[];
|
||||
|
||||
/* Shaders */
|
||||
|
||||
struct BASIC_Shaders {
|
||||
/* Depth Pre Pass */
|
||||
GPUShader *depth;
|
||||
GPUShader *pointcloud_depth;
|
||||
GPUShader *curves_depth;
|
||||
GPUShader *depth_conservative;
|
||||
GPUShader *pointcloud_depth_conservative;
|
||||
};
|
||||
|
||||
static struct {
|
||||
BASIC_Shaders sh_data[GPU_SHADER_CFG_LEN];
|
||||
} e_data = {{{nullptr}}}; /* Engine data */
|
||||
|
||||
GPUShader *BASIC_shaders_depth_sh_get(eGPUShaderConfig config)
|
||||
{
|
||||
BASIC_Shaders *sh_data = &e_data.sh_data[config];
|
||||
if (sh_data->depth == nullptr) {
|
||||
sh_data->depth = GPU_shader_create_from_info_name(
|
||||
config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_mesh_clipped" : "basic_depth_mesh");
|
||||
}
|
||||
return sh_data->depth;
|
||||
}
|
||||
|
||||
GPUShader *BASIC_shaders_pointcloud_depth_sh_get(eGPUShaderConfig config)
|
||||
{
|
||||
BASIC_Shaders *sh_data = &e_data.sh_data[config];
|
||||
if (sh_data->pointcloud_depth == nullptr) {
|
||||
sh_data->pointcloud_depth = GPU_shader_create_from_info_name(
|
||||
config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_pointcloud_clipped" :
|
||||
"basic_depth_pointcloud");
|
||||
}
|
||||
return sh_data->pointcloud_depth;
|
||||
}
|
||||
|
||||
GPUShader *BASIC_shaders_curves_depth_sh_get(eGPUShaderConfig config)
|
||||
{
|
||||
BASIC_Shaders *sh_data = &e_data.sh_data[config];
|
||||
if (sh_data->curves_depth == nullptr) {
|
||||
sh_data->curves_depth = GPU_shader_create_from_info_name(
|
||||
config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_curves_clipped" : "basic_depth_curves");
|
||||
}
|
||||
return sh_data->curves_depth;
|
||||
}
|
||||
|
||||
GPUShader *BASIC_shaders_depth_conservative_sh_get(eGPUShaderConfig config)
|
||||
{
|
||||
BASIC_Shaders *sh_data = &e_data.sh_data[config];
|
||||
if (sh_data->depth_conservative == nullptr) {
|
||||
sh_data->depth_conservative = GPU_shader_create_from_info_name(
|
||||
config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_mesh_conservative_clipped" :
|
||||
"basic_depth_mesh_conservative");
|
||||
}
|
||||
return sh_data->depth_conservative;
|
||||
}
|
||||
|
||||
GPUShader *BASIC_shaders_pointcloud_depth_conservative_sh_get(eGPUShaderConfig config)
|
||||
{
|
||||
BASIC_Shaders *sh_data = &e_data.sh_data[config];
|
||||
if (sh_data->pointcloud_depth_conservative == nullptr) {
|
||||
sh_data->pointcloud_depth_conservative = GPU_shader_create_from_info_name(
|
||||
config == GPU_SHADER_CFG_CLIPPED ? "basic_depth_pointcloud_conservative_clipped" :
|
||||
"basic_depth_pointcloud_conservative");
|
||||
}
|
||||
return sh_data->pointcloud_depth_conservative;
|
||||
}
|
||||
|
||||
void BASIC_shaders_free()
|
||||
{
|
||||
for (int i = 0; i < GPU_SHADER_CFG_LEN; i++) {
|
||||
GPUShader **sh_data_as_array = (GPUShader **)&e_data.sh_data[i];
|
||||
for (int j = 0; j < (sizeof(BASIC_Shaders) / sizeof(GPUShader *)); j++) {
|
||||
DRW_SHADER_FREE_SAFE(sh_data_as_array[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2020-2022 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/* Adaptation of Conservative Rasterization
|
||||
* from GPU Gems 2
|
||||
* Using method 2.
|
||||
*
|
||||
* Actual final implementation does not do conservative rasterization and only
|
||||
* avoids triangles producing no fragments.
|
||||
*/
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Compute plane normal in NDC space. */
|
||||
vec3 pos0 = gl_in[0].gl_Position.xyz / gl_in[0].gl_Position.w;
|
||||
vec3 pos1 = gl_in[1].gl_Position.xyz / gl_in[1].gl_Position.w;
|
||||
vec3 pos2 = gl_in[2].gl_Position.xyz / gl_in[2].gl_Position.w;
|
||||
vec3 plane = normalize(cross(pos1 - pos0, pos2 - pos0));
|
||||
/* Compute NDC bound box. */
|
||||
vec4 bbox = vec4(min(min(pos0.xy, pos1.xy), pos2.xy), max(max(pos0.xy, pos1.xy), pos2.xy));
|
||||
/* Convert to pixel space. */
|
||||
bbox = (bbox * 0.5 + 0.5) * sizeViewport.xyxy;
|
||||
/* Detect failure cases where triangles would produce no fragments. */
|
||||
bvec2 is_subpixel = lessThan(bbox.zw - bbox.xy, vec2(1.0));
|
||||
/* View aligned triangle. */
|
||||
const float threshold = 0.00001;
|
||||
bool is_coplanar = abs(plane.z) < threshold;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
if (all(is_subpixel)) {
|
||||
vec2 ofs = (i == 0) ? vec2(-1.0) : ((i == 1) ? vec2(2.0, -1.0) : vec2(-1.0, 2.0));
|
||||
/* HACK: Fix cases where the triangle is too small make it cover at least one pixel. */
|
||||
gl_Position.xy += sizeViewportInv * gl_Position.w * ofs;
|
||||
}
|
||||
/* Test if the triangle is almost parallel with the view to avoid precision issues. */
|
||||
else if (any(is_subpixel) || is_coplanar) {
|
||||
/* HACK: Fix cases where the triangle is Parallel to the view by deforming it slightly. */
|
||||
vec2 ofs = (i == 0) ? vec2(-1.0) : ((i == 1) ? vec2(1.0, -1.0) : vec2(1.0));
|
||||
gl_Position.xy += sizeViewportInv * gl_Position.w * ofs;
|
||||
}
|
||||
else {
|
||||
/* Triangle expansion should happen here, but we decide to not implement it for
|
||||
* depth precision & performance reasons. */
|
||||
}
|
||||
|
||||
view_clipping_distances_set(gl_in[i]);
|
||||
gpu_EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2020-2022 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Passthrough shader. */
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2017-2022 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "common_view_clipping_lib.glsl"
|
||||
#include "common_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);
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Conservative Rasterization
|
||||
*
|
||||
* Allow selection of sub-pixel objects.
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_CREATE_INFO(basic_conservative)
|
||||
GEOMETRY_LAYOUT(PrimitiveIn::TRIANGLES, PrimitiveOut::TRIANGLE_STRIP, 3)
|
||||
GEOMETRY_SOURCE("basic_conservative_depth_geom.glsl")
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Object types
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_CREATE_INFO(basic_mesh)
|
||||
VERTEX_IN(0, VEC3, pos)
|
||||
VERTEX_SOURCE("basic_depth_vert.glsl")
|
||||
ADDITIONAL_INFO(draw_mesh)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(basic_pointcloud)
|
||||
VERTEX_SOURCE("basic_depth_pointcloud_vert.glsl")
|
||||
ADDITIONAL_INFO(draw_pointcloud)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(basic_curves)
|
||||
VERTEX_SOURCE("basic_depth_curves_vert.glsl")
|
||||
ADDITIONAL_INFO(draw_hair)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Variations Declaration
|
||||
* \{ */
|
||||
|
||||
#define BASIC_CLIPPING_VARIATIONS(prefix, ...) \
|
||||
CREATE_INFO_VARIANT(prefix##_clipped, drw_clipped, __VA_ARGS__) \
|
||||
CREATE_INFO_VARIANT(prefix, __VA_ARGS__)
|
||||
|
||||
#define BASIC_CONSERVATIVE_VARIATIONS(prefix, ...) \
|
||||
BASIC_CLIPPING_VARIATIONS(prefix##_conservative, basic_conservative, __VA_ARGS__) \
|
||||
BASIC_CLIPPING_VARIATIONS(prefix, __VA_ARGS__)
|
||||
|
||||
#define BASIC_OBTYPE_VARIATIONS(prefix, ...) \
|
||||
BASIC_CONSERVATIVE_VARIATIONS(prefix##_mesh, basic_mesh, __VA_ARGS__) \
|
||||
BASIC_CONSERVATIVE_VARIATIONS(prefix##_pointcloud, basic_pointcloud, __VA_ARGS__) \
|
||||
BASIC_CLIPPING_VARIATIONS(prefix##_curves, basic_curves, __VA_ARGS__)
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Depth shader types.
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_CREATE_INFO(basic_depth)
|
||||
FRAGMENT_SOURCE("basic_depth_frag.glsl")
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
BASIC_OBTYPE_VARIATIONS(basic_depth, basic_depth, draw_globals)
|
||||
|
||||
/** \} */
|
||||
@@ -923,7 +923,7 @@ GPU_SHADER_CREATE_END()
|
||||
GPU_SHADER_CREATE_INFO(overlay_depth_mesh)
|
||||
DO_STATIC_COMPILATION()
|
||||
VERTEX_IN(0, VEC3, pos)
|
||||
VERTEX_SOURCE("basic_depth_vert.glsl")
|
||||
VERTEX_SOURCE("overlay_depth_only_vert.glsl")
|
||||
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
|
||||
ADDITIONAL_INFO(draw_globals)
|
||||
ADDITIONAL_INFO(draw_view)
|
||||
@@ -974,7 +974,7 @@ GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_depth_pointcloud)
|
||||
DO_STATIC_COMPILATION()
|
||||
VERTEX_SOURCE("basic_depth_pointcloud_vert.glsl")
|
||||
VERTEX_SOURCE("overlay_depth_only_pointcloud_vert.glsl")
|
||||
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
|
||||
ADDITIONAL_INFO(draw_pointcloud_new)
|
||||
ADDITIONAL_INFO(draw_globals)
|
||||
@@ -985,7 +985,7 @@ GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_depth_curves)
|
||||
DO_STATIC_COMPILATION()
|
||||
VERTEX_SOURCE("basic_depth_curves_vert.glsl")
|
||||
VERTEX_SOURCE("overlay_depth_only_curves_vert.glsl")
|
||||
FRAGMENT_SOURCE("overlay_depth_only_frag.glsl")
|
||||
ADDITIONAL_INFO(draw_hair_new)
|
||||
ADDITIONAL_INFO(draw_globals)
|
||||
|
||||
@@ -88,7 +88,6 @@
|
||||
/* only for callbacks */
|
||||
#include "draw_cache_impl.hh"
|
||||
|
||||
#include "engines/basic/basic_engine.h"
|
||||
#include "engines/compositor/compositor_engine.h"
|
||||
#include "engines/eevee_next/eevee_engine.h"
|
||||
#include "engines/external/external_engine.h"
|
||||
@@ -1197,13 +1196,6 @@ static void drw_engines_enable_overlays()
|
||||
{
|
||||
use_drw_engine(&draw_engine_overlay_next_type);
|
||||
}
|
||||
/**
|
||||
* Use for select and depth-drawing.
|
||||
*/
|
||||
static void drw_engines_enable_basic()
|
||||
{
|
||||
use_drw_engine(&draw_engine_basic_type);
|
||||
}
|
||||
|
||||
static void drw_engine_enable_image_editor()
|
||||
{
|
||||
@@ -2626,7 +2618,6 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph,
|
||||
View3D *v3d,
|
||||
GPUViewport *viewport,
|
||||
const bool use_gpencil,
|
||||
const bool use_basic,
|
||||
const bool use_overlay,
|
||||
const bool use_only_selected)
|
||||
{
|
||||
@@ -2659,9 +2650,6 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph,
|
||||
if (use_gpencil) {
|
||||
use_drw_engine(&draw_engine_gpencil_type);
|
||||
}
|
||||
if (use_basic) {
|
||||
drw_engines_enable_basic();
|
||||
}
|
||||
if (use_overlay) {
|
||||
drw_engines_enable_overlays();
|
||||
}
|
||||
@@ -3057,7 +3045,6 @@ void DRW_engines_register()
|
||||
DRW_engine_register(&draw_engine_overlay_next_type);
|
||||
DRW_engine_register(&draw_engine_select_next_type);
|
||||
DRW_engine_register(&draw_engine_select_type);
|
||||
DRW_engine_register(&draw_engine_basic_type);
|
||||
DRW_engine_register(&draw_engine_compositor_type);
|
||||
#ifdef WITH_DRAW_DEBUG
|
||||
DRW_engine_register(&draw_engine_debug_select_type);
|
||||
|
||||
@@ -2427,20 +2427,20 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
|
||||
if (viewport != nullptr) {
|
||||
switch (mode) {
|
||||
case V3D_DEPTH_ALL:
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, true, use_overlay, false);
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, use_overlay, false);
|
||||
break;
|
||||
case V3D_DEPTH_NO_GPENCIL:
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, false, true, use_overlay, false);
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, use_overlay, false);
|
||||
break;
|
||||
case V3D_DEPTH_GPENCIL_ONLY:
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, false, use_overlay, false);
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, false, use_overlay, false);
|
||||
break;
|
||||
case V3D_DEPTH_OBJECT_ONLY:
|
||||
DRW_draw_depth_object(
|
||||
scene, region, v3d, viewport, DEG_get_evaluated_object(depsgraph, obact));
|
||||
break;
|
||||
case V3D_DEPTH_SELECTED_ONLY:
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, false, true, use_overlay, true);
|
||||
DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, use_overlay, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,9 +117,6 @@
|
||||
#include "draw_object_infos_info.hh"
|
||||
#include "draw_view_info.hh"
|
||||
|
||||
/* Basic engine. */
|
||||
#include "basic_depth_info.hh"
|
||||
|
||||
/* EEVEE engine. */
|
||||
#include "eevee_ambient_occlusion_info.hh"
|
||||
#include "eevee_common_info.hh"
|
||||
|
||||
Reference in New Issue
Block a user