2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2016 Blender Foundation. */
|
2018-04-13 15:49:50 +02:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup draw_engine
|
2018-04-13 15:49:50 +02:00
|
|
|
*
|
2020-03-11 17:07:43 +01:00
|
|
|
* Workbench Engine:
|
|
|
|
|
*
|
|
|
|
|
* Optimized engine to draw the working viewport with solid and transparent geometry.
|
2018-04-13 15:49:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "DRW_render.h"
|
|
|
|
|
|
2020-03-11 17:07:43 +01:00
|
|
|
#include "BLI_alloca.h"
|
|
|
|
|
|
2022-02-04 11:57:52 +01:00
|
|
|
#include "BKE_editmesh.h"
|
2022-10-12 20:55:26 -05:00
|
|
|
#include "BKE_mesh_runtime.h"
|
2020-03-11 17:07:43 +01:00
|
|
|
#include "BKE_modifier.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_paint.h"
|
|
|
|
|
#include "BKE_particle.h"
|
2022-04-05 11:42:55 -07:00
|
|
|
#include "BKE_pbvh.h"
|
2020-03-11 17:07:43 +01:00
|
|
|
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
#include "DNA_curves_types.h"
|
2020-03-11 17:07:43 +01:00
|
|
|
#include "DNA_fluid_types.h"
|
2020-03-17 16:27:08 +01:00
|
|
|
#include "DNA_image_types.h"
|
2020-03-11 17:07:43 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_modifier_types.h"
|
|
|
|
|
#include "DNA_node_types.h"
|
2022-10-25 10:43:47 +02:00
|
|
|
#include "DNA_pointcloud_types.h"
|
2020-03-11 17:07:43 +01:00
|
|
|
|
2022-04-08 16:37:35 +02:00
|
|
|
#include "ED_paint.h"
|
|
|
|
|
|
2022-09-22 18:03:29 +02:00
|
|
|
#include "GPU_context.h"
|
|
|
|
|
|
2018-04-13 15:49:50 +02:00
|
|
|
#include "workbench_engine.h"
|
2018-07-11 11:43:56 +02:00
|
|
|
#include "workbench_private.h"
|
2018-04-13 15:49:50 +02:00
|
|
|
|
2018-11-26 19:00:01 +01:00
|
|
|
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
|
2018-04-13 15:49:50 +02:00
|
|
|
|
2020-03-11 17:07:43 +01:00
|
|
|
void workbench_engine_init(void *ved)
|
|
|
|
|
{
|
2022-09-22 18:03:29 +02:00
|
|
|
GPU_render_begin();
|
2020-03-11 17:07:43 +01:00
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
WORKBENCH_StorageList *stl = vedata->stl;
|
|
|
|
|
WORKBENCH_TextureList *txl = vedata->txl;
|
|
|
|
|
|
2021-01-26 17:40:35 +01:00
|
|
|
workbench_private_data_alloc(stl);
|
2020-03-11 17:07:43 +01:00
|
|
|
WORKBENCH_PrivateData *wpd = stl->wpd;
|
|
|
|
|
workbench_private_data_init(wpd);
|
|
|
|
|
workbench_update_world_ubo(wpd);
|
|
|
|
|
|
|
|
|
|
if (txl->dummy_image_tx == NULL) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f};
|
2020-03-11 17:07:43 +01:00
|
|
|
txl->dummy_image_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, 0, fpixel);
|
|
|
|
|
}
|
|
|
|
|
wpd->dummy_image_tx = txl->dummy_image_tx;
|
|
|
|
|
|
|
|
|
|
if (OBJECT_ID_PASS_ENABLED(wpd)) {
|
|
|
|
|
wpd->object_id_tx = DRW_texture_pool_query_fullscreen(GPU_R16UI, &draw_engine_workbench);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-03-18 09:35:12 +11:00
|
|
|
/* Don't free because it's a pool texture. */
|
2020-03-11 17:07:43 +01:00
|
|
|
wpd->object_id_tx = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_opaque_engine_init(vedata);
|
|
|
|
|
workbench_transparent_engine_init(vedata);
|
|
|
|
|
workbench_dof_engine_init(vedata);
|
|
|
|
|
workbench_antialiasing_engine_init(vedata);
|
|
|
|
|
workbench_volume_engine_init(vedata);
|
2022-09-22 18:03:29 +02:00
|
|
|
GPU_render_end();
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void workbench_cache_init(void *ved)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
|
|
|
|
|
workbench_opaque_cache_init(vedata);
|
|
|
|
|
workbench_transparent_cache_init(vedata);
|
|
|
|
|
workbench_shadow_cache_init(vedata);
|
|
|
|
|
workbench_cavity_cache_init(vedata);
|
|
|
|
|
workbench_outline_cache_init(vedata);
|
|
|
|
|
workbench_dof_cache_init(vedata);
|
|
|
|
|
workbench_antialiasing_cache_init(vedata);
|
|
|
|
|
workbench_volume_cache_init(vedata);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-19 14:32:41 +10:00
|
|
|
/* TODO(fclem): DRW_cache_object_surface_material_get needs a refactor to allow passing NULL
|
2020-03-11 17:07:43 +01:00
|
|
|
* instead of gpumat_array. Avoiding all this boilerplate code. */
|
|
|
|
|
static struct GPUBatch **workbench_object_surface_material_get(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
const int materials_len = DRW_cache_object_material_count_get(ob);
|
|
|
|
|
struct 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 workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
|
|
|
|
|
Object *ob,
|
|
|
|
|
eV3DShadingColorType color_type)
|
|
|
|
|
{
|
|
|
|
|
const bool use_single_drawcall = !ELEM(color_type, V3D_SHADING_MATERIAL_COLOR);
|
|
|
|
|
if (use_single_drawcall) {
|
2022-06-08 12:30:01 -07:00
|
|
|
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, ob->actcol, color_type, NULL);
|
2022-09-28 14:51:23 -07:00
|
|
|
|
|
|
|
|
bool use_color = color_type == V3D_SHADING_VERTEX_COLOR;
|
|
|
|
|
bool use_uv = color_type == V3D_SHADING_TEXTURE_COLOR;
|
|
|
|
|
|
|
|
|
|
DRW_shgroup_call_sculpt(grp, ob, false, false, false, use_color, use_uv);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const int materials_len = DRW_cache_object_material_count_get(ob);
|
|
|
|
|
struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len);
|
|
|
|
|
for (int i = 0; i < materials_len; i++) {
|
|
|
|
|
shgrps[i] = workbench_material_setup(wpd, ob, i + 1, color_type, NULL);
|
|
|
|
|
}
|
2022-09-28 14:51:23 -07:00
|
|
|
DRW_shgroup_call_sculpt_with_materials(shgrps, NULL, materials_len, ob);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 20:10:45 +02:00
|
|
|
BLI_INLINE void workbench_object_drawcall(DRWShadingGroup *grp, struct GPUBatch *geom, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
if (ob->type == OB_POINTCLOUD) {
|
2021-07-21 20:40:03 +10:00
|
|
|
/* Draw range to avoid drawcall batching messing up the instance attribute. */
|
2020-07-15 20:10:45 +02:00
|
|
|
DRW_shgroup_call_instance_range(grp, ob, geom, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DRW_shgroup_call(grp, geom, ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 17:07:43 +01:00
|
|
|
static void workbench_cache_texpaint_populate(WORKBENCH_PrivateData *wpd, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const Scene *scene = draw_ctx->scene;
|
|
|
|
|
const ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
|
|
|
|
|
const bool use_single_drawcall = imapaint->mode == IMAGEPAINT_MODE_IMAGE;
|
|
|
|
|
|
|
|
|
|
if (use_single_drawcall) {
|
|
|
|
|
struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
|
|
|
|
|
if (geom) {
|
|
|
|
|
Image *ima = imapaint->canvas;
|
2020-06-08 10:58:45 +02:00
|
|
|
eGPUSamplerState state = GPU_SAMPLER_REPEAT;
|
|
|
|
|
SET_FLAG_FROM_TEST(state, imapaint->interp == IMAGEPAINT_INTERP_LINEAR, GPU_SAMPLER_FILTER);
|
2020-03-11 17:07:43 +01:00
|
|
|
|
2020-06-08 10:58:45 +02:00
|
|
|
DRWShadingGroup *grp = workbench_image_setup(wpd, ob, 0, ima, NULL, state);
|
2020-07-15 20:10:45 +02:00
|
|
|
workbench_object_drawcall(grp, geom, ob);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
struct GPUBatch **geoms = DRW_cache_mesh_surface_texpaint_get(ob);
|
|
|
|
|
if (geoms) {
|
|
|
|
|
const int materials_len = DRW_cache_object_material_count_get(ob);
|
|
|
|
|
for (int i = 0; i < materials_len; i++) {
|
2020-05-08 00:50:21 +02:00
|
|
|
if (geoms[i] == NULL) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
DRWShadingGroup *grp = workbench_image_setup(wpd, ob, i + 1, NULL, NULL, 0);
|
2020-07-15 20:10:45 +02:00
|
|
|
workbench_object_drawcall(grp, geoms[i], ob);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void workbench_cache_common_populate(WORKBENCH_PrivateData *wpd,
|
|
|
|
|
Object *ob,
|
|
|
|
|
eV3DShadingColorType color_type,
|
|
|
|
|
bool *r_transp)
|
|
|
|
|
{
|
|
|
|
|
const bool use_tex = ELEM(color_type, V3D_SHADING_TEXTURE_COLOR);
|
|
|
|
|
const bool use_vcol = ELEM(color_type, V3D_SHADING_VERTEX_COLOR);
|
|
|
|
|
const bool use_single_drawcall = !ELEM(
|
|
|
|
|
color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_TEXTURE_COLOR);
|
|
|
|
|
|
|
|
|
|
if (use_single_drawcall) {
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
struct GPUBatch *geom;
|
|
|
|
|
if (use_vcol) {
|
|
|
|
|
if (ob->mode & OB_MODE_VERTEX_PAINT) {
|
|
|
|
|
geom = DRW_cache_mesh_surface_vertpaint_get(ob);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-04-05 11:42:55 -07:00
|
|
|
geom = DRW_cache_mesh_surface_sculptcolors_get(ob);
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
geom = DRW_cache_object_surface_get(ob);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 17:07:43 +01:00
|
|
|
if (geom) {
|
|
|
|
|
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, r_transp);
|
2020-07-15 20:10:45 +02:00
|
|
|
workbench_object_drawcall(grp, geom, ob);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
struct GPUBatch **geoms = (use_tex) ? DRW_cache_mesh_surface_texpaint_get(ob) :
|
|
|
|
|
workbench_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++) {
|
2020-05-08 00:50:21 +02:00
|
|
|
if (geoms[i] == NULL) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, i + 1, color_type, r_transp);
|
2020-07-15 20:10:45 +02:00
|
|
|
workbench_object_drawcall(grp, geoms[i], ob);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void workbench_cache_hair_populate(WORKBENCH_PrivateData *wpd,
|
|
|
|
|
Object *ob,
|
2020-03-17 16:27:08 +01:00
|
|
|
ParticleSystem *psys,
|
2020-03-11 17:07:43 +01:00
|
|
|
ModifierData *md,
|
|
|
|
|
eV3DShadingColorType color_type,
|
2020-03-17 16:27:08 +01:00
|
|
|
bool use_texpaint_mode,
|
|
|
|
|
const int matnr)
|
2020-03-11 17:07:43 +01:00
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const Scene *scene = draw_ctx->scene;
|
|
|
|
|
|
|
|
|
|
const ImagePaintSettings *imapaint = use_texpaint_mode ? &scene->toolsettings->imapaint : NULL;
|
|
|
|
|
Image *ima = (imapaint && imapaint->mode == IMAGEPAINT_MODE_IMAGE) ? imapaint->canvas : NULL;
|
2020-06-08 10:58:45 +02:00
|
|
|
eGPUSamplerState state = 0;
|
2020-06-09 10:59:19 +02:00
|
|
|
state |= (imapaint && imapaint->interp == IMAGEPAINT_INTERP_LINEAR) ? GPU_SAMPLER_FILTER : 0;
|
2020-03-11 17:07:43 +01:00
|
|
|
DRWShadingGroup *grp = (use_texpaint_mode) ?
|
2020-06-08 10:58:45 +02:00
|
|
|
workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, state) :
|
2020-03-17 16:27:08 +01:00
|
|
|
workbench_material_hair_setup(wpd, ob, matnr, color_type);
|
2020-03-11 17:07:43 +01:00
|
|
|
|
2021-09-24 07:42:36 +02:00
|
|
|
DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-04 11:57:52 +01:00
|
|
|
static const CustomData *workbench_mesh_get_loop_custom_data(const Mesh *mesh)
|
|
|
|
|
{
|
2022-10-12 20:55:26 -05:00
|
|
|
if (BKE_mesh_wrapper_type(mesh) == ME_WRAPPER_TYPE_BMESH) {
|
2022-02-04 11:57:52 +01:00
|
|
|
BLI_assert(mesh->edit_mesh != NULL);
|
|
|
|
|
BLI_assert(mesh->edit_mesh->bm != NULL);
|
|
|
|
|
return &mesh->edit_mesh->bm->ldata;
|
|
|
|
|
}
|
|
|
|
|
return &mesh->ldata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const CustomData *workbench_mesh_get_vert_custom_data(const Mesh *mesh)
|
|
|
|
|
{
|
2022-10-12 20:55:26 -05:00
|
|
|
if (BKE_mesh_wrapper_type(mesh) == ME_WRAPPER_TYPE_BMESH) {
|
2022-02-04 11:57:52 +01:00
|
|
|
BLI_assert(mesh->edit_mesh != NULL);
|
|
|
|
|
BLI_assert(mesh->edit_mesh->bm != NULL);
|
|
|
|
|
return &mesh->edit_mesh->bm->vdata;
|
|
|
|
|
}
|
|
|
|
|
return &mesh->vdata;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-14 15:34:24 +11:00
|
|
|
/**
|
|
|
|
|
* Decide what color-type to draw the object with.
|
|
|
|
|
* In some cases it can be overwritten by #workbench_material_setup().
|
|
|
|
|
*/
|
2020-03-11 17:07:43 +01:00
|
|
|
static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd,
|
|
|
|
|
Object *ob,
|
|
|
|
|
bool *r_sculpt_pbvh,
|
|
|
|
|
bool *r_texpaint_mode,
|
|
|
|
|
bool *r_draw_shadow)
|
|
|
|
|
{
|
|
|
|
|
eV3DShadingColorType color_type = wpd->shading.color_type;
|
|
|
|
|
const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
|
2022-02-05 17:52:04 -06:00
|
|
|
const CustomData *ldata = (me == NULL) ? NULL : workbench_mesh_get_loop_custom_data(me);
|
2020-03-11 17:07:43 +01:00
|
|
|
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const bool is_active = (ob == draw_ctx->obact);
|
2022-10-26 18:01:45 +02:00
|
|
|
const bool is_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
|
2020-03-11 17:07:43 +01:00
|
|
|
!DRW_state_is_image_render();
|
|
|
|
|
const bool is_render = DRW_state_is_image_render() && (draw_ctx->v3d == NULL);
|
|
|
|
|
const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE);
|
|
|
|
|
const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX);
|
|
|
|
|
|
2022-04-05 11:42:55 -07:00
|
|
|
/* Needed for mesh cache validation, to prevent two copies of
|
|
|
|
|
* of vertex color arrays from being sent to the GPU (e.g.
|
|
|
|
|
* when switching from eevee to workbench).
|
|
|
|
|
*/
|
|
|
|
|
if (ob->sculpt && ob->sculpt->pbvh) {
|
|
|
|
|
BKE_pbvh_is_drawing_set(ob->sculpt->pbvh, is_sculpt_pbvh);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 00:58:19 -07:00
|
|
|
bool has_color = false;
|
2022-04-20 22:03:45 -07:00
|
|
|
|
2022-04-21 00:58:19 -07:00
|
|
|
if (me) {
|
|
|
|
|
const CustomData *cd_vdata = workbench_mesh_get_vert_custom_data(me);
|
|
|
|
|
const CustomData *cd_ldata = workbench_mesh_get_loop_custom_data(me);
|
|
|
|
|
|
|
|
|
|
has_color = (CustomData_has_layer(cd_vdata, CD_PROP_COLOR) ||
|
|
|
|
|
CustomData_has_layer(cd_vdata, CD_PROP_BYTE_COLOR) ||
|
|
|
|
|
CustomData_has_layer(cd_ldata, CD_PROP_COLOR) ||
|
|
|
|
|
CustomData_has_layer(cd_ldata, CD_PROP_BYTE_COLOR));
|
|
|
|
|
}
|
2022-04-20 22:03:45 -07:00
|
|
|
|
2020-07-01 16:44:31 +10:00
|
|
|
if (color_type == V3D_SHADING_TEXTURE_COLOR) {
|
|
|
|
|
if (ob->dt < OB_TEXTURE) {
|
|
|
|
|
color_type = V3D_SHADING_MATERIAL_COLOR;
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
}
|
2022-02-04 11:57:52 +01:00
|
|
|
else if ((me == NULL) || !CustomData_has_layer(ldata, CD_MLOOPUV)) {
|
2020-07-01 16:44:31 +10:00
|
|
|
/* Disable color mode if data layer is unavailable. */
|
|
|
|
|
color_type = V3D_SHADING_MATERIAL_COLOR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (color_type == V3D_SHADING_VERTEX_COLOR) {
|
2022-04-05 11:42:55 -07:00
|
|
|
if (!me) {
|
|
|
|
|
color_type = V3D_SHADING_OBJECT_COLOR;
|
2020-07-09 17:16:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2022-04-05 11:42:55 -07:00
|
|
|
if (!has_color) {
|
2020-07-09 17:16:24 +02:00
|
|
|
color_type = V3D_SHADING_OBJECT_COLOR;
|
|
|
|
|
}
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
|
2020-03-17 16:27:08 +01:00
|
|
|
if (r_sculpt_pbvh) {
|
|
|
|
|
*r_sculpt_pbvh = is_sculpt_pbvh;
|
|
|
|
|
}
|
|
|
|
|
if (r_texpaint_mode) {
|
|
|
|
|
*r_texpaint_mode = false;
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
|
|
|
|
|
if (!is_sculpt_pbvh && !is_render) {
|
|
|
|
|
/* Force texture or vertex mode if object is in paint mode. */
|
2022-02-04 11:57:52 +01:00
|
|
|
if (is_texpaint_mode && me && CustomData_has_layer(ldata, CD_MLOOPUV)) {
|
2020-03-11 17:07:43 +01:00
|
|
|
color_type = V3D_SHADING_TEXTURE_COLOR;
|
2020-03-17 16:27:08 +01:00
|
|
|
if (r_texpaint_mode) {
|
|
|
|
|
*r_texpaint_mode = true;
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
2022-04-20 22:03:45 -07:00
|
|
|
else if (is_vertpaint_mode && me && has_color) {
|
2020-03-11 17:07:43 +01:00
|
|
|
color_type = V3D_SHADING_VERTEX_COLOR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 12:30:01 -07:00
|
|
|
if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR &&
|
|
|
|
|
BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES) {
|
2020-08-24 16:24:51 +02:00
|
|
|
/* Force use of material color for sculpt. */
|
|
|
|
|
color_type = V3D_SHADING_MATERIAL_COLOR;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 16:37:35 +02:00
|
|
|
if (is_sculpt_pbvh) {
|
|
|
|
|
/* Bad call C is required to access the tool system that is context aware. Cast to non-const
|
|
|
|
|
* due to current API. */
|
|
|
|
|
bContext *C = (bContext *)DRW_context_state_get()->evil_C;
|
|
|
|
|
if (C != NULL) {
|
|
|
|
|
color_type = ED_paint_shading_color_override(
|
|
|
|
|
C, &wpd->scene->toolsettings->paint_mode, ob, color_type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 17:07:43 +01:00
|
|
|
if (r_draw_shadow) {
|
|
|
|
|
*r_draw_shadow = (ob->dtx & OB_DRAW_NO_SHADOW_CAST) == 0 && SHADOW_ENABLED(wpd);
|
|
|
|
|
/* Currently unsupported in sculpt mode. We could revert to the slow
|
|
|
|
|
* method in this case but I'm not sure if it's a good idea given that
|
|
|
|
|
* sculpted meshes are heavy to begin with. */
|
|
|
|
|
if (is_sculpt_pbvh) {
|
|
|
|
|
*r_draw_shadow = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_active && DRW_object_use_hide_faces(ob)) {
|
|
|
|
|
*r_draw_shadow = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return color_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void workbench_cache_populate(void *ved, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
WORKBENCH_StorageList *stl = vedata->stl;
|
|
|
|
|
WORKBENCH_PrivateData *wpd = stl->wpd;
|
|
|
|
|
|
|
|
|
|
if (!DRW_object_is_renderable(ob)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH && ob->modifiers.first != NULL) {
|
2020-03-17 16:27:08 +01:00
|
|
|
bool use_texpaint_mode;
|
|
|
|
|
int color_type = workbench_color_type_get(wpd, ob, NULL, &use_texpaint_mode, NULL);
|
2020-03-11 17:07:43 +01:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
|
|
|
|
if (md->type != eModifierType_ParticleSystem) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
|
|
|
|
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) {
|
2020-03-17 16:27:08 +01:00
|
|
|
workbench_cache_hair_populate(
|
|
|
|
|
wpd, ob, psys, md, color_type, use_texpaint_mode, part->omat);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(ob->base_flag & BASE_FROM_DUPLI)) {
|
2020-05-08 10:14:02 +02:00
|
|
|
ModifierData *md = BKE_modifiers_findby_type(ob, eModifierType_Fluid);
|
|
|
|
|
if (md && BKE_modifier_is_enabled(wpd->scene, md, eModifierMode_Realtime)) {
|
2020-03-11 17:07:43 +01:00
|
|
|
FluidModifierData *fmd = (FluidModifierData *)md;
|
2020-09-15 21:21:14 +05:30
|
|
|
if (fmd->domain) {
|
2020-03-17 16:27:08 +01:00
|
|
|
workbench_volume_cache_populate(vedata, wpd->scene, ob, md, V3D_SHADING_SINGLE_COLOR);
|
2020-09-15 21:21:14 +05:30
|
|
|
if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS) {
|
|
|
|
|
return; /* Do not draw solid in this case. */
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ob->dt < OB_SOLID) && !DRW_state_is_scene_render()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 10:43:47 +02:00
|
|
|
if (ob->type == OB_MESH) {
|
2020-03-11 17:07:43 +01:00
|
|
|
bool use_sculpt_pbvh, use_texpaint_mode, draw_shadow, has_transp_mat = false;
|
|
|
|
|
eV3DShadingColorType color_type = workbench_color_type_get(
|
|
|
|
|
wpd, ob, &use_sculpt_pbvh, &use_texpaint_mode, &draw_shadow);
|
|
|
|
|
|
|
|
|
|
if (use_sculpt_pbvh) {
|
|
|
|
|
workbench_cache_sculpt_populate(wpd, ob, color_type);
|
|
|
|
|
}
|
|
|
|
|
else if (use_texpaint_mode) {
|
|
|
|
|
workbench_cache_texpaint_populate(wpd, ob);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
workbench_cache_common_populate(wpd, ob, color_type, &has_transp_mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (draw_shadow) {
|
|
|
|
|
workbench_shadow_cache_populate(vedata, ob, has_transp_mat);
|
|
|
|
|
}
|
|
|
|
|
}
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
else if (ob->type == OB_CURVES) {
|
2020-03-17 16:27:08 +01:00
|
|
|
int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
|
2022-04-13 22:07:31 -05:00
|
|
|
DRWShadingGroup *grp = workbench_material_hair_setup(wpd, ob, CURVES_MATERIAL_NR, color_type);
|
|
|
|
|
DRW_shgroup_curves_create_sub(ob, grp, NULL);
|
2020-03-17 16:27:08 +01:00
|
|
|
}
|
2022-10-25 10:43:47 +02:00
|
|
|
else if (ob->type == OB_POINTCLOUD) {
|
|
|
|
|
int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
|
|
|
|
|
DRWShadingGroup *grp = workbench_material_ptcloud_setup(
|
|
|
|
|
wpd, ob, POINTCLOUD_MATERIAL_NR, color_type);
|
|
|
|
|
DRW_shgroup_pointcloud_create_sub(ob, grp, NULL);
|
|
|
|
|
}
|
2020-03-17 16:27:08 +01:00
|
|
|
else if (ob->type == OB_VOLUME) {
|
|
|
|
|
if (wpd->shading.type != OB_WIRE) {
|
|
|
|
|
int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL);
|
|
|
|
|
workbench_volume_cache_populate(vedata, wpd->scene, ob, NULL, color_type);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void workbench_cache_finish(void *ved)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
WORKBENCH_StorageList *stl = vedata->stl;
|
|
|
|
|
WORKBENCH_FramebufferList *fbl = vedata->fbl;
|
|
|
|
|
WORKBENCH_PrivateData *wpd = stl->wpd;
|
|
|
|
|
|
2020-09-19 14:32:41 +10:00
|
|
|
/* TODO(fclem): Only do this when really needed. */
|
2020-03-11 17:07:43 +01:00
|
|
|
{
|
2020-07-01 13:12:24 +10:00
|
|
|
/* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */
|
2020-03-11 17:07:43 +01:00
|
|
|
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
|
|
|
|
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
|
|
|
|
|
|
|
|
|
DRW_texture_ensure_fullscreen_2d(&dtxl->depth_in_front, GPU_DEPTH24_STENCIL8, 0);
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_ensure_config(&dfbl->in_front_fb,
|
|
|
|
|
{
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(dtxl->color),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_ensure_config(&fbl->opaque_infront_fb,
|
|
|
|
|
{
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->material_buffer_tx),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->normal_buffer_tx),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_ensure_config(&fbl->transp_accum_infront_fb,
|
|
|
|
|
{
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->accum_buffer_tx),
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->reveal_buffer_tx),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wpd->object_id_tx) {
|
|
|
|
|
GPU_framebuffer_ensure_config(&fbl->id_clear_fb,
|
|
|
|
|
{
|
|
|
|
|
GPU_ATTACHMENT_NONE,
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(wpd->object_id_tx),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GPU_FRAMEBUFFER_FREE_SAFE(fbl->id_clear_fb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_update_material_ubos(wpd);
|
|
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: don't free reuse next redraw. */
|
2020-03-11 17:07:43 +01:00
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
|
for (int j = 0; j < 2; j++) {
|
2020-07-15 20:10:45 +02:00
|
|
|
for (int k = 0; k < WORKBENCH_DATATYPE_MAX; k++) {
|
2020-03-11 17:07:43 +01:00
|
|
|
if (wpd->prepass[i][j][k].material_hash) {
|
|
|
|
|
BLI_ghash_free(wpd->prepass[i][j][k].material_hash, NULL, NULL);
|
|
|
|
|
wpd->prepass[i][j][k].material_hash = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void workbench_draw_sample(void *ved)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
WORKBENCH_FramebufferList *fbl = vedata->fbl;
|
|
|
|
|
WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
|
|
|
|
|
WORKBENCH_PassList *psl = vedata->psl;
|
|
|
|
|
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
2020-08-07 22:36:11 +10:00
|
|
|
const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
const float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
2020-03-11 17:07:43 +01:00
|
|
|
|
|
|
|
|
const bool do_render = workbench_antialiasing_setup(vedata);
|
|
|
|
|
const bool xray_is_visible = wpd->shading.xray_alpha > 0.0f;
|
|
|
|
|
const bool do_transparent_infront_pass = !DRW_pass_is_empty(psl->transp_accum_infront_ps);
|
|
|
|
|
const bool do_transparent_pass = !DRW_pass_is_empty(psl->transp_accum_ps);
|
|
|
|
|
const bool do_opaque_infront_pass = !DRW_pass_is_empty(psl->opaque_infront_ps);
|
|
|
|
|
const bool do_opaque_pass = !DRW_pass_is_empty(psl->opaque_ps) || do_opaque_infront_pass;
|
|
|
|
|
|
|
|
|
|
if (dfbl->in_front_fb) {
|
|
|
|
|
GPU_framebuffer_bind(dfbl->in_front_fb);
|
|
|
|
|
GPU_framebuffer_clear_depth(dfbl->in_front_fb, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_render) {
|
|
|
|
|
GPU_framebuffer_bind(dfbl->default_fb);
|
|
|
|
|
GPU_framebuffer_clear_color_depth_stencil(dfbl->default_fb, wpd->background_color, 1.0f, 0x00);
|
|
|
|
|
|
|
|
|
|
if (fbl->id_clear_fb) {
|
|
|
|
|
GPU_framebuffer_bind(fbl->id_clear_fb);
|
|
|
|
|
GPU_framebuffer_clear_color(fbl->id_clear_fb, clear_col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_opaque_pass) {
|
|
|
|
|
GPU_framebuffer_bind(fbl->opaque_fb);
|
|
|
|
|
DRW_draw_pass(psl->opaque_ps);
|
|
|
|
|
|
|
|
|
|
if (psl->shadow_ps[0]) {
|
|
|
|
|
DRW_draw_pass(psl->shadow_ps[0]);
|
|
|
|
|
DRW_draw_pass(psl->shadow_ps[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_opaque_infront_pass) {
|
|
|
|
|
GPU_framebuffer_bind(fbl->opaque_infront_fb);
|
|
|
|
|
DRW_draw_pass(psl->opaque_infront_ps);
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_bind(fbl->opaque_fb);
|
|
|
|
|
DRW_draw_pass(psl->merge_infront_ps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_bind(dfbl->default_fb);
|
|
|
|
|
DRW_draw_pass(psl->composite_ps);
|
|
|
|
|
|
|
|
|
|
if (psl->cavity_ps) {
|
|
|
|
|
GPU_framebuffer_bind(dfbl->color_only_fb);
|
|
|
|
|
DRW_draw_pass(psl->cavity_ps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_volume_draw_pass(vedata);
|
|
|
|
|
|
|
|
|
|
if (xray_is_visible) {
|
|
|
|
|
if (do_transparent_pass) {
|
|
|
|
|
GPU_framebuffer_bind(fbl->transp_accum_fb);
|
|
|
|
|
GPU_framebuffer_clear_color(fbl->transp_accum_fb, clear_col_with_alpha);
|
|
|
|
|
|
|
|
|
|
DRW_draw_pass(psl->transp_accum_ps);
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_bind(dfbl->color_only_fb);
|
|
|
|
|
DRW_draw_pass(psl->transp_resolve_ps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_transparent_infront_pass) {
|
|
|
|
|
GPU_framebuffer_bind(fbl->transp_accum_infront_fb);
|
|
|
|
|
GPU_framebuffer_clear_color(fbl->transp_accum_infront_fb, clear_col_with_alpha);
|
|
|
|
|
|
|
|
|
|
DRW_draw_pass(psl->transp_accum_infront_ps);
|
|
|
|
|
|
|
|
|
|
GPU_framebuffer_bind(dfbl->color_only_fb);
|
|
|
|
|
DRW_draw_pass(psl->transp_resolve_ps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_transparent_draw_depth_pass(vedata);
|
|
|
|
|
|
|
|
|
|
if (psl->outline_ps) {
|
|
|
|
|
GPU_framebuffer_bind(dfbl->color_only_fb);
|
|
|
|
|
DRW_draw_pass(psl->outline_ps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_dof_draw_pass(vedata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_antialiasing_draw_pass(vedata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Viewport rendering. */
|
|
|
|
|
static void workbench_draw_scene(void *ved)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *vedata = ved;
|
|
|
|
|
WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
|
|
|
|
|
|
|
|
|
|
if (DRW_state_is_opengl_render()) {
|
|
|
|
|
while (wpd->taa_sample < max_ii(1, wpd->taa_sample_len)) {
|
|
|
|
|
workbench_update_world_ubo(wpd);
|
|
|
|
|
|
|
|
|
|
workbench_draw_sample(vedata);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
workbench_draw_sample(vedata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbench_draw_finish(vedata);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-18 15:45:32 +02:00
|
|
|
void workbench_draw_finish(void *UNUSED(ved))
|
2020-03-11 17:07:43 +01:00
|
|
|
{
|
2020-03-15 22:49:20 +01:00
|
|
|
/* Reset default view. */
|
|
|
|
|
DRW_view_set_active(NULL);
|
2020-03-11 17:07:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void workbench_engine_free(void)
|
|
|
|
|
{
|
|
|
|
|
workbench_shader_free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void workbench_view_update(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
WORKBENCH_Data *data = vedata;
|
|
|
|
|
workbench_antialiasing_view_updated(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void workbench_id_update(void *UNUSED(vedata), struct ID *id)
|
|
|
|
|
{
|
|
|
|
|
if (GS(id->name) == ID_OB) {
|
|
|
|
|
WORKBENCH_ObjectData *oed = (WORKBENCH_ObjectData *)DRW_drawdata_get(id,
|
|
|
|
|
&draw_engine_workbench);
|
|
|
|
|
if (oed != NULL && oed->dd.recalc != 0) {
|
|
|
|
|
oed->shadow_bbox_dirty = (oed->dd.recalc & ID_RECALC_ALL) != 0;
|
|
|
|
|
oed->dd.recalc = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
|
|
|
|
|
|
|
|
|
|
DrawEngineType draw_engine_workbench = {
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
N_("Workbench"),
|
|
|
|
|
&workbench_data_size,
|
|
|
|
|
&workbench_engine_init,
|
|
|
|
|
&workbench_engine_free,
|
2021-12-07 10:33:55 +01:00
|
|
|
NULL, /* instance_free */
|
2020-03-11 17:07:43 +01:00
|
|
|
&workbench_cache_init,
|
|
|
|
|
&workbench_cache_populate,
|
|
|
|
|
&workbench_cache_finish,
|
|
|
|
|
&workbench_draw_scene,
|
|
|
|
|
&workbench_view_update,
|
|
|
|
|
&workbench_id_update,
|
|
|
|
|
&workbench_render,
|
2021-01-05 14:59:45 +01:00
|
|
|
NULL,
|
2020-03-11 17:07:43 +01:00
|
|
|
};
|
|
|
|
|
|
2018-11-26 19:00:01 +01:00
|
|
|
RenderEngineType DRW_engine_viewport_workbench_type = {
|
2018-04-13 15:49:50 +02:00
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2018-11-26 19:00:01 +01:00
|
|
|
WORKBENCH_ENGINE,
|
|
|
|
|
N_("Workbench"),
|
2020-07-20 13:56:29 +02:00
|
|
|
RE_INTERNAL | RE_USE_STEREO_VIEWPORT | RE_USE_GPU_CONTEXT,
|
2018-07-11 11:43:56 +02:00
|
|
|
NULL,
|
|
|
|
|
&DRW_render_to_image,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
NULL,
|
|
|
|
|
NULL,
|
2018-07-11 11:43:56 +02:00
|
|
|
&workbench_render_update_passes,
|
2020-03-11 17:07:43 +01:00
|
|
|
&draw_engine_workbench,
|
2019-01-31 08:28:56 +11:00
|
|
|
{NULL, NULL, NULL},
|
2018-04-13 15:49:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#undef WORKBENCH_ENGINE
|