2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2016 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup draw
|
2017-02-07 11:20:15 +01:00
|
|
|
*/
|
|
|
|
|
2017-05-08 03:44:58 +02:00
|
|
|
#pragma once
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2022-03-26 11:53:24 +01:00
|
|
|
#include "draw_common_shader_shared.h"
|
|
|
|
|
2022-04-08 20:52:35 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
EEVEE: support Curves attributes rendering
This adds support to render Curves attributes in EEVEE.
Each attribute is stored in a texture derived from a VBO. As the
shading group needs the textures to be valid upon creation, the
attributes are created and setup during its very creation, instead
of doing it lazily via create_requested which we cannot rely on
anyway as contrary to the mesh batch, we do cannot really tell if
attributes need to be updated or else via some `DRW_batch_requested`.
Since point attributes need refinement, and since attributes are all
cast to vec4/float4 to account for differences in type conversions
between Blender and OpenGL, the refinement shader for points is
used as is. The point attributes are stored for each subdivision level
in CurvesEvalFinalCache. Each subdivision level also keeps track of the
attributes already in use so they are properly updated when needed.
Some basic garbage collection was added similar to what is done
for meshes: if the attributes used over time have been different
from the currently used attributes for too long, then the buffers
are freed, ensuring that stale attributesare removed.
This adds `CurvesInfos` to the shader creation info, which stores
the scope in which the attributes are defined. Scopes are stored
as booleans, in an array indexed by attribute loading order which
is also the order in which the attributes were added to the material.
A mapping is necessary between the indices used for the scoping, and
the ones used in the Curves cache, as this may contain stale
attributes which have not been garbage collected yet.
Common utilities with the mesh code for handling requested
attributes were moved to a separate file.
Differential Revision: https://developer.blender.org/D14916
2022-05-24 05:02:57 +02:00
|
|
|
struct CurvesUniformBufPool;
|
2017-03-08 20:00:09 +01:00
|
|
|
struct DRWShadingGroup;
|
2020-09-30 03:51:13 +02:00
|
|
|
struct FluidModifierData;
|
2022-01-24 11:16:06 +01:00
|
|
|
struct GPUMaterial;
|
2018-05-29 12:11:03 +02:00
|
|
|
struct ModifierData;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct Object;
|
|
|
|
struct ParticleSystem;
|
2020-07-30 00:41:03 +02:00
|
|
|
struct RegionView3D;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct ViewLayer;
|
2022-04-19 12:01:16 +02:00
|
|
|
struct Scene;
|
2022-04-18 15:45:32 +02:00
|
|
|
struct DRWData;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-03-01 18:54:58 +01:00
|
|
|
/* Keep in sync with globalsBlock in shaders */
|
2018-09-29 21:56:47 +02:00
|
|
|
BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
|
2017-03-01 18:54:58 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
void DRW_globals_update(void);
|
2018-02-14 18:59:15 +01:00
|
|
|
void DRW_globals_free(void);
|
2017-03-01 18:54:58 +01:00
|
|
|
|
2019-12-02 01:40:58 +01:00
|
|
|
struct DRWView *DRW_view_create_with_zoffset(const struct DRWView *parent_view,
|
2020-07-30 00:41:03 +02:00
|
|
|
const struct RegionView3D *rv3d,
|
2019-12-02 01:40:58 +01:00
|
|
|
float offset);
|
2019-05-26 01:13:20 +02:00
|
|
|
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* Get the wire color theme_id of an object based on its state
|
|
|
|
* \a r_color is a way to get a pointer to the static color var associated
|
|
|
|
*/
|
2018-02-06 06:10:03 +01:00
|
|
|
int DRW_object_wire_theme_get(struct Object *ob, struct ViewLayer *view_layer, float **r_color);
|
2017-04-10 22:22:37 +02:00
|
|
|
float *DRW_color_background_blend_get(int theme_id);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2020-07-30 00:41:03 +02:00
|
|
|
bool DRW_object_is_flat(struct Object *ob, int *r_axis);
|
|
|
|
bool DRW_object_axis_orthogonal_to_view(struct Object *ob, int axis);
|
2018-09-14 18:30:26 +02:00
|
|
|
|
2022-05-12 17:25:57 +02:00
|
|
|
/* draw_hair.cc */
|
2018-05-29 12:11:03 +02:00
|
|
|
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* This creates a shading group with display hairs.
|
|
|
|
* The draw call is already added by this function, just add additional uniforms.
|
|
|
|
*/
|
2020-03-11 17:07:43 +01:00
|
|
|
struct DRWShadingGroup *DRW_shgroup_hair_create_sub(struct Object *object,
|
|
|
|
struct ParticleSystem *psys,
|
|
|
|
struct ModifierData *md,
|
2021-09-24 07:42:36 +02:00
|
|
|
struct DRWShadingGroup *shgrp,
|
|
|
|
struct GPUMaterial *gpu_material);
|
2022-04-14 05:07:31 +02:00
|
|
|
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* \note Only valid after #DRW_hair_update().
|
|
|
|
*/
|
2020-06-23 13:59:55 +02:00
|
|
|
struct GPUVertBuf *DRW_hair_pos_buffer_get(struct Object *object,
|
|
|
|
struct ParticleSystem *psys,
|
|
|
|
struct ModifierData *md);
|
|
|
|
void DRW_hair_duplimat_get(struct Object *object,
|
|
|
|
struct ParticleSystem *psys,
|
|
|
|
struct ModifierData *md,
|
|
|
|
float (*dupli_mat)[4]);
|
2020-03-11 17:07:43 +01:00
|
|
|
|
2018-06-02 20:45:03 +02:00
|
|
|
void DRW_hair_init(void);
|
|
|
|
void DRW_hair_update(void);
|
2018-05-29 12:11:03 +02:00
|
|
|
void DRW_hair_free(void);
|
|
|
|
|
2022-04-22 17:43:48 +02:00
|
|
|
/* draw_curves.cc */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \note Only valid after #DRW_curves_update().
|
|
|
|
*/
|
|
|
|
struct GPUVertBuf *DRW_curves_pos_buffer_get(struct Object *object);
|
|
|
|
|
|
|
|
struct DRWShadingGroup *DRW_shgroup_curves_create_sub(struct Object *object,
|
|
|
|
struct DRWShadingGroup *shgrp,
|
|
|
|
struct GPUMaterial *gpu_material);
|
|
|
|
|
EEVEE: support Curves attributes rendering
This adds support to render Curves attributes in EEVEE.
Each attribute is stored in a texture derived from a VBO. As the
shading group needs the textures to be valid upon creation, the
attributes are created and setup during its very creation, instead
of doing it lazily via create_requested which we cannot rely on
anyway as contrary to the mesh batch, we do cannot really tell if
attributes need to be updated or else via some `DRW_batch_requested`.
Since point attributes need refinement, and since attributes are all
cast to vec4/float4 to account for differences in type conversions
between Blender and OpenGL, the refinement shader for points is
used as is. The point attributes are stored for each subdivision level
in CurvesEvalFinalCache. Each subdivision level also keeps track of the
attributes already in use so they are properly updated when needed.
Some basic garbage collection was added similar to what is done
for meshes: if the attributes used over time have been different
from the currently used attributes for too long, then the buffers
are freed, ensuring that stale attributesare removed.
This adds `CurvesInfos` to the shader creation info, which stores
the scope in which the attributes are defined. Scopes are stored
as booleans, in an array indexed by attribute loading order which
is also the order in which the attributes were added to the material.
A mapping is necessary between the indices used for the scoping, and
the ones used in the Curves cache, as this may contain stale
attributes which have not been garbage collected yet.
Common utilities with the mesh code for handling requested
attributes were moved to a separate file.
Differential Revision: https://developer.blender.org/D14916
2022-05-24 05:02:57 +02:00
|
|
|
void DRW_curves_init(struct DRWData *drw_data);
|
|
|
|
void DRW_curves_ubos_pool_free(struct CurvesUniformBufPool *pool);
|
2022-04-22 17:43:48 +02:00
|
|
|
void DRW_curves_update(void);
|
|
|
|
void DRW_curves_free(void);
|
|
|
|
|
2022-10-25 10:43:47 +02:00
|
|
|
/* draw_pointcloud.cc */
|
|
|
|
|
|
|
|
struct DRWShadingGroup *DRW_shgroup_pointcloud_create_sub(struct Object *object,
|
|
|
|
struct DRWShadingGroup *shgrp_parent,
|
|
|
|
struct GPUMaterial *gpu_material);
|
|
|
|
void DRW_pointcloud_init(void);
|
|
|
|
void DRW_pointcloud_free(void);
|
|
|
|
|
2022-04-19 12:01:16 +02:00
|
|
|
/* draw_volume.cc */
|
|
|
|
|
|
|
|
/**
|
2022-04-20 01:16:24 +02:00
|
|
|
* Add attributes bindings of volume grids to an existing shading group.
|
2022-04-19 12:01:16 +02:00
|
|
|
* No draw call is added so the caller can decide how to use the data.
|
2022-06-07 17:07:04 +02:00
|
|
|
* \return nullptr if there is nothing to draw.
|
2022-04-19 12:01:16 +02:00
|
|
|
*/
|
|
|
|
struct DRWShadingGroup *DRW_shgroup_volume_create_sub(struct Scene *scene,
|
|
|
|
struct Object *ob,
|
|
|
|
struct DRWShadingGroup *shgrp,
|
|
|
|
struct GPUMaterial *gpu_material);
|
|
|
|
|
|
|
|
void DRW_volume_init(struct DRWData *drw_data);
|
|
|
|
void DRW_volume_ubos_pool_free(void *pool);
|
|
|
|
void DRW_volume_free(void);
|
|
|
|
|
2023-07-31 03:50:54 +02:00
|
|
|
/* `draw_fluid.cc` */
|
2020-07-29 23:21:33 +02:00
|
|
|
|
2021-06-24 07:56:58 +02:00
|
|
|
/* Fluid simulation. */
|
2020-07-29 23:21:33 +02:00
|
|
|
void DRW_smoke_ensure(struct FluidModifierData *fmd, int highres);
|
|
|
|
void DRW_smoke_ensure_coba_field(struct FluidModifierData *fmd);
|
|
|
|
void DRW_smoke_ensure_velocity(struct FluidModifierData *fmd);
|
2020-09-15 17:51:14 +02:00
|
|
|
void DRW_fluid_ensure_flags(struct FluidModifierData *fmd);
|
|
|
|
void DRW_fluid_ensure_range_field(struct FluidModifierData *fmd);
|
2020-07-29 23:21:33 +02:00
|
|
|
|
|
|
|
void DRW_smoke_free(struct FluidModifierData *fmd);
|
2022-04-18 15:45:32 +02:00
|
|
|
|
|
|
|
void DRW_smoke_init(struct DRWData *drw_data);
|
|
|
|
void DRW_smoke_exit(struct DRWData *drw_data);
|
2020-07-29 23:21:33 +02:00
|
|
|
|
2023-07-31 03:50:54 +02:00
|
|
|
/* `draw_common.cc` */
|
2021-12-08 10:29:39 +01:00
|
|
|
|
2019-01-22 02:09:27 +01:00
|
|
|
struct DRW_Global {
|
|
|
|
/** If needed, contains all global/Theme colors
|
|
|
|
* Add needed theme colors / values to DRW_globals_update() and update UBO
|
|
|
|
* Not needed for constant color. */
|
|
|
|
GlobalsUboStorage block;
|
2021-06-24 07:56:58 +02:00
|
|
|
/** Define "globalsBlock" uniform for 'block'. */
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf *block_ubo;
|
2019-01-22 02:09:27 +01:00
|
|
|
|
|
|
|
struct GPUTexture *ramp;
|
|
|
|
struct GPUTexture *weight_ramp;
|
2019-02-23 08:31:45 +01:00
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
struct GPUUniformBuf *view_ubo;
|
2022-10-07 00:06:27 +02:00
|
|
|
struct GPUUniformBuf *clipping_ubo;
|
2019-01-22 02:09:27 +01:00
|
|
|
};
|
|
|
|
extern struct DRW_Global G_draw;
|
2022-04-08 20:52:35 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|