Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_private.h')
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h245
1 files changed, 107 insertions, 138 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index fefdaef970a..28a8983cfee 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -23,9 +23,12 @@
#ifndef __EEVEE_PRIVATE_H__
#define __EEVEE_PRIVATE_H__
+#include "DRW_render.h"
+
+#include "BLI_bitmap.h"
+
#include "DNA_lightprobe_types.h"
-struct EEVEE_BoundSphere;
struct EEVEE_ShadowCasterBuffer;
struct GPUFrameBuffer;
struct Object;
@@ -39,11 +42,13 @@ extern struct DrawEngineType draw_engine_eevee_type;
#define MAX_PLANAR 16 /* TODO : find size by dividing UBO max size by grid data size */
#define MAX_LIGHT 128 /* TODO : find size by dividing UBO max size by light data size */
#define MAX_CASCADE_NUM 4
-#define MAX_SHADOW 256 /* TODO : Make this depends on GL_MAX_ARRAY_TEXTURE_LAYERS */
+#define MAX_SHADOW 128 /* TODO : Make this depends on GL_MAX_ARRAY_TEXTURE_LAYERS */
#define MAX_SHADOW_CASCADE 8
#define MAX_SHADOW_CUBE (MAX_SHADOW - MAX_CASCADE_NUM * MAX_SHADOW_CASCADE)
#define MAX_BLOOM_STEP 16
+// #define DEBUG_SHADOW_DISTRIBUTION
+
/* Only define one of these. */
// #define IRRADIANCE_SH_L2
// #define IRRADIANCE_CUBEMAP
@@ -150,14 +155,12 @@ enum {
VAR_MAT_PROBE = (1 << 1),
VAR_MAT_HAIR = (1 << 2),
VAR_MAT_BLEND = (1 << 3),
- VAR_MAT_VSM = (1 << 4),
- VAR_MAT_ESM = (1 << 5),
- VAR_MAT_VOLUME = (1 << 6),
- VAR_MAT_LOOKDEV = (1 << 7),
+ VAR_MAT_VOLUME = (1 << 4),
+ VAR_MAT_LOOKDEV = (1 << 5),
/* Max number of variation */
/* IMPORTANT : Leave it last and set
* it's value accordingly. */
- VAR_MAT_MAX = (1 << 8),
+ VAR_MAT_MAX = (1 << 6),
/* These are options that are not counted in VAR_MAT_MAX
* because they are not cumulative with the others above. */
VAR_MAT_CLIP = (1 << 9),
@@ -165,8 +168,6 @@ enum {
VAR_MAT_MULT = (1 << 11),
VAR_MAT_SHADOW = (1 << 12),
VAR_MAT_REFRACT = (1 << 13),
- VAR_MAT_TRANSLUC = (1 << 15),
- VAR_MAT_SSSALBED = (1 << 16),
};
/* ************ PROBE UBO ************* */
@@ -190,10 +191,6 @@ typedef struct EEVEE_PlanarReflection {
/* --------------------------------------- */
-typedef struct EEVEE_BoundSphere {
- float center[3], radius;
-} EEVEE_BoundSphere;
-
typedef struct EEVEE_BoundBox {
float center[3], halfdim[3];
} EEVEE_BoundBox;
@@ -201,12 +198,6 @@ typedef struct EEVEE_BoundBox {
typedef struct EEVEE_PassList {
/* Shadows */
struct DRWPass *shadow_pass;
- struct DRWPass *shadow_cube_copy_pass;
- struct DRWPass *shadow_cube_store_pass;
- struct DRWPass *shadow_cube_store_high_pass;
- struct DRWPass *shadow_cascade_copy_pass;
- struct DRWPass *shadow_cascade_store_pass;
- struct DRWPass *shadow_cascade_store_high_pass;
/* Probes */
struct DRWPass *probe_background;
@@ -242,6 +233,7 @@ typedef struct EEVEE_PassList {
struct DRWPass *sss_blur_ps;
struct DRWPass *sss_resolve_ps;
struct DRWPass *sss_accum_ps;
+ struct DRWPass *sss_translucency_ps;
struct DRWPass *color_downsample_ps;
struct DRWPass *color_downsample_cube_ps;
struct DRWPass *velocity_resolve;
@@ -292,6 +284,7 @@ typedef struct EEVEE_FramebufferList {
struct GPUFrameBuffer *sss_blit_fb;
struct GPUFrameBuffer *sss_resolve_fb;
struct GPUFrameBuffer *sss_clear_fb;
+ struct GPUFrameBuffer *sss_translucency_fb;
struct GPUFrameBuffer *sss_accum_fb;
struct GPUFrameBuffer *dof_down_fb;
struct GPUFrameBuffer *dof_scatter_fb;
@@ -368,7 +361,7 @@ typedef struct EEVEE_StorageList {
typedef struct EEVEE_Light {
float position[3], invsqrdist;
float color[3], spec;
- float spotsize, spotblend, radius, shadowid;
+ float spotsize, spotblend, radius, shadow_id;
float rightvec[3], sizex;
float upvec[3], sizey;
float forwardvec[3], light_type;
@@ -378,13 +371,13 @@ typedef struct EEVEE_Light {
#define LAMPTYPE_AREA_ELLIPSE 100.0f
typedef struct EEVEE_Shadow {
- float near, far, bias, exp;
- float shadow_start, data_start, multi_shadow_count, shadow_blur;
+ float near, far, bias, type_data_id;
float contact_dist, contact_bias, contact_spread, contact_thickness;
} EEVEE_Shadow;
typedef struct EEVEE_ShadowCube {
- float position[3], pad;
+ float shadowmat[4][4];
+ float position[3], _pad0[1];
} EEVEE_ShadowCube;
typedef struct EEVEE_ShadowCascade {
@@ -392,42 +385,34 @@ typedef struct EEVEE_ShadowCascade {
float shadowmat[MAX_CASCADE_NUM][4][4];
float split_start[4];
float split_end[4];
+ float shadow_vec[3], tex_id;
} EEVEE_ShadowCascade;
-typedef struct EEVEE_ShadowRender {
- int shadow_samples_len[MAX_CASCADE_NUM];
- float shadow_samples_len_inv[MAX_CASCADE_NUM];
- float filter_size[MAX_CASCADE_NUM];
- int view_count;
- int base_id;
- float cube_texel_size;
- float stored_texel_size;
- float clip_near;
- float clip_far;
- float exponent;
- float pad;
-} EEVEE_ShadowRender;
+typedef struct EEVEE_ShadowCascadeRender {
+ /* World->Light->NDC : used for rendering the shadow map. */
+ float projmat[MAX_CASCADE_NUM][4][4];
+ float viewmat[4][4], viewinv[4][4];
+ float radius[MAX_CASCADE_NUM];
+ float cascade_max_dist;
+ float cascade_exponent;
+ float cascade_fade;
+ int cascade_count;
+} EEVEE_ShadowCascadeRender;
BLI_STATIC_ASSERT_ALIGN(EEVEE_Light, 16)
BLI_STATIC_ASSERT_ALIGN(EEVEE_Shadow, 16)
BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowCube, 16)
BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowCascade, 16)
-BLI_STATIC_ASSERT_ALIGN(EEVEE_ShadowRender, 16)
-
-/* This is just a really long bitflag with special function to access it. */
-#define MAX_LIGHTBITS_FIELDS (MAX_LIGHT / 8)
-typedef struct EEVEE_LightBits {
- uchar fields[MAX_LIGHTBITS_FIELDS];
-} EEVEE_LightBits;
-typedef struct EEVEE_ShadowCaster {
- struct EEVEE_LightBits bits;
- struct EEVEE_BoundBox bbox;
-} EEVEE_ShadowCaster;
+BLI_STATIC_ASSERT(sizeof(EEVEE_Shadow) * MAX_SHADOW +
+ sizeof(EEVEE_ShadowCascade) * MAX_SHADOW_CASCADE +
+ sizeof(EEVEE_ShadowCube) * MAX_SHADOW_CUBE <
+ 16384,
+ "Shadow UBO is too big!!!")
typedef struct EEVEE_ShadowCasterBuffer {
- struct EEVEE_ShadowCaster *shadow_casters;
- char *flags;
+ struct EEVEE_BoundBox *bbox;
+ BLI_bitmap *update;
uint alloc_count;
uint count;
} EEVEE_ShadowCasterBuffer;
@@ -437,42 +422,31 @@ typedef struct EEVEE_LightsInfo {
int num_light, cache_num_light;
int num_cube_layer, cache_num_cube_layer;
int num_cascade_layer, cache_num_cascade_layer;
- int gpu_cube_len, gpu_cascade_len, gpu_shadow_len;
- int cpu_cube_len, cpu_cascade_len;
- int update_flag;
- int shadow_cube_size, shadow_cascade_size, shadow_method;
+ int cube_len, cascade_len, shadow_len;
+ int shadow_cube_size, shadow_cascade_size;
bool shadow_high_bitdepth, soft_shadows;
- int shadow_cube_store_size;
- /* List of lights in the scene. */
- /* XXX This is fragile, can get out of sync quickly. */
- struct Object *light_ref[MAX_LIGHT];
- struct Object *shadow_cube_ref[MAX_SHADOW_CUBE];
- struct Object *shadow_cascade_ref[MAX_SHADOW_CASCADE];
/* UBO Storage : data used by UBO */
struct EEVEE_Light light_data[MAX_LIGHT];
- struct EEVEE_ShadowRender shadow_render_data;
struct EEVEE_Shadow shadow_data[MAX_SHADOW];
struct EEVEE_ShadowCube shadow_cube_data[MAX_SHADOW_CUBE];
struct EEVEE_ShadowCascade shadow_cascade_data[MAX_SHADOW_CASCADE];
+ /* Additionnal rendering info for cascade. */
+ struct EEVEE_ShadowCascadeRender shadow_cascade_render[MAX_SHADOW_CASCADE];
+ /* Back index in light_data. */
+ uchar shadow_cube_light_indices[MAX_SHADOW_CUBE];
+ uchar shadow_cascade_light_indices[MAX_SHADOW_CASCADE];
+ /* Update bitmap. */
+ BLI_bitmap sh_cube_update[BLI_BITMAP_SIZE(MAX_SHADOW_CUBE)];
/* Lights tracking */
- int new_shadow_id[MAX_LIGHT]; /* To be able to convert old bitfield to new bitfield */
- struct EEVEE_BoundSphere shadow_bounds[MAX_LIGHT]; /* Tightly packed light bounds */
- /* Pointers only. */
- struct EEVEE_ShadowCasterBuffer *shcaster_frontbuffer;
- struct EEVEE_ShadowCasterBuffer *shcaster_backbuffer;
+ struct BoundSphere shadow_bounds[MAX_LIGHT]; /* Tightly packed light bounds */
+ /* List of bbox and update bitmap. Double buffered. */
+ struct EEVEE_ShadowCasterBuffer *shcaster_frontbuffer, *shcaster_backbuffer;
+ /* AABB of all shadow casters combined. */
+ struct {
+ float min[3], max[3];
+ } shcaster_aabb;
} EEVEE_LightsInfo;
-/* EEVEE_LightsInfo->shadow_casters_flag */
-enum {
- SHADOW_CASTER_PRUNED = (1 << 0),
- SHADOW_CASTER_UPDATED = (1 << 1),
-};
-
-/* EEVEE_LightsInfo->update_flag */
-enum {
- LIGHT_UPDATE_SHADOW_CUBE = (1 << 0),
-};
-
/* ************ PROBE DATA ************* */
typedef struct EEVEE_LightProbeVisTest {
struct Collection *collection; /* Skip test if NULL */
@@ -552,8 +526,8 @@ typedef struct EEVEE_EffectsInfo {
bool swap_double_buffer;
/* SSSS */
int sss_sample_count;
- bool sss_separate_albedo;
- struct GPUTexture *sss_data; /* Textures from pool */
+ struct GPUTexture *sss_irradiance; /* Textures from pool */
+ struct GPUTexture *sss_radius;
struct GPUTexture *sss_albedo;
struct GPUTexture *sss_blur;
struct GPUTexture *sss_stencil;
@@ -711,20 +685,10 @@ typedef struct EEVEE_ViewLayerData {
struct GPUUniformBuffer *light_ubo;
struct GPUUniformBuffer *shadow_ubo;
- struct GPUUniformBuffer *shadow_render_ubo;
struct GPUUniformBuffer *shadow_samples_ubo;
- struct GPUFrameBuffer *shadow_cube_target_fb;
- struct GPUFrameBuffer *shadow_cube_store_fb;
- struct GPUFrameBuffer *shadow_cube_copy_fb;
- struct GPUFrameBuffer *shadow_cascade_target_fb;
- struct GPUFrameBuffer *shadow_cascade_store_fb;
- struct GPUFrameBuffer *shadow_cascade_copy_fb;
-
- struct GPUTexture *shadow_cube_target;
- struct GPUTexture *shadow_cube_blur;
- struct GPUTexture *shadow_cascade_target;
- struct GPUTexture *shadow_cascade_blur;
+ struct GPUFrameBuffer *shadow_fb;
+
struct GPUTexture *shadow_cube_pool;
struct GPUTexture *shadow_cascade_pool;
@@ -746,23 +710,6 @@ typedef struct EEVEE_ViewLayerData {
/* ************ OBJECT DATA ************ */
-typedef struct EEVEE_LightData {
- short light_id, shadow_id;
-} EEVEE_LightData;
-
-typedef struct EEVEE_ShadowCubeData {
- short light_id, shadow_id, cube_id, layer_id;
-} EEVEE_ShadowCubeData;
-
-typedef struct EEVEE_ShadowCascadeData {
- short light_id, shadow_id, cascade_id, layer_id;
- /* World->Light->NDC : used for rendering the shadow map. */
- float viewprojmat[MAX_CASCADE_NUM][4][4]; /* Could be removed. */
- float projmat[MAX_CASCADE_NUM][4][4];
- float viewmat[4][4], viewinv[4][4];
- float radius[MAX_CASCADE_NUM];
-} EEVEE_ShadowCascadeData;
-
/* These are the structs stored inside Objects.
* It works even if the object is in multiple layers
* because we don't get the same "Object *" for each layer. */
@@ -770,13 +717,6 @@ typedef struct EEVEE_LightEngineData {
DrawData dd;
bool need_update;
- /* This needs to be out of the union to avoid undefined behavior. */
- short prev_cube_shadow_id;
- union {
- struct EEVEE_LightData ld;
- struct EEVEE_ShadowCubeData scd;
- struct EEVEE_ShadowCascadeData scad;
- } data;
} EEVEE_LightEngineData;
typedef struct EEVEE_LightProbeEngineData {
@@ -895,43 +835,67 @@ void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
struct GPUMaterial *EEVEE_material_world_volume_get(struct Scene *scene, struct World *wo);
-struct GPUMaterial *EEVEE_material_mesh_get(struct Scene *scene,
- Material *ma,
- EEVEE_Data *vedata,
- bool use_blend,
- bool use_refract,
- bool use_translucency,
- int shadow_method);
+struct GPUMaterial *EEVEE_material_mesh_get(
+ struct Scene *scene, Material *ma, EEVEE_Data *vedata, bool use_blend, bool use_refract);
struct GPUMaterial *EEVEE_material_mesh_volume_get(struct Scene *scene, Material *ma);
struct GPUMaterial *EEVEE_material_mesh_depth_get(struct Scene *scene,
Material *ma,
bool use_hashed_alpha,
bool is_shadow);
-struct GPUMaterial *EEVEE_material_hair_get(struct Scene *scene, Material *ma, int shadow_method);
+struct GPUMaterial *EEVEE_material_hair_get(struct Scene *scene, Material *ma);
void EEVEE_materials_free(void);
-void EEVEE_draw_default_passes(EEVEE_PassList *psl);
+void EEVEE_materials_draw_opaque(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl);
void EEVEE_update_noise(EEVEE_PassList *psl, EEVEE_FramebufferList *fbl, const double offsets[3]);
void EEVEE_update_viewvecs(float invproj[4][4], float winmat[4][4], float (*r_viewvecs)[4]);
/* eevee_lights.c */
-void EEVEE_lights_init(EEVEE_ViewLayerData *sldata);
+void eevee_light_matrix_get(const EEVEE_Light *evli, float r_mat[4][4]);
void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, struct Object *ob);
-void EEVEE_lights_cache_shcaster_add(EEVEE_ViewLayerData *sldata,
- EEVEE_StorageList *stl,
- struct GPUBatch *geom,
- Object *ob);
-void EEVEE_lights_cache_shcaster_material_add(EEVEE_ViewLayerData *sldata,
- EEVEE_PassList *psl,
- struct GPUMaterial *gpumat,
- struct GPUBatch *geom,
- struct Object *ob,
- const float *alpha_threshold);
-void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob);
void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
-void EEVEE_lights_update(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
-void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct DRWView *view);
-void EEVEE_lights_free(void);
+
+/* eevee_shadows.c */
+void eevee_contact_shadow_setup(const Light *la, EEVEE_Shadow *evsh);
+void EEVEE_shadows_init(EEVEE_ViewLayerData *sldata);
+void EEVEE_shadows_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_shadows_caster_add(EEVEE_ViewLayerData *sldata,
+ EEVEE_StorageList *stl,
+ struct GPUBatch *geom,
+ Object *ob);
+void EEVEE_shadows_caster_material_add(EEVEE_ViewLayerData *sldata,
+ EEVEE_PassList *psl,
+ struct GPUMaterial *gpumat,
+ struct GPUBatch *geom,
+ struct Object *ob,
+ const float *alpha_threshold);
+void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, struct Object *ob);
+void EEVEE_shadows_update(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_shadows_cube_add(EEVEE_LightsInfo *linfo, EEVEE_Light *evli, struct Object *ob);
+bool EEVEE_shadows_cube_setup(EEVEE_LightsInfo *linfo, const EEVEE_Light *evli, int sample_ofs);
+void EEVEE_shadows_cascade_add(EEVEE_LightsInfo *linfo, EEVEE_Light *evli, struct Object *ob);
+void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, struct DRWView *view);
+void EEVEE_shadows_draw_cubemap(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int cube_index);
+void EEVEE_shadows_draw_cascades(EEVEE_ViewLayerData *sldata,
+ EEVEE_Data *vedata,
+ DRWView *view,
+ int cascade_index);
+void EEVEE_shadows_free(void);
+
+/* eevee_sampling.c */
+void EEVEE_sample_ball(int sample_ofs, float radius, float rsample[3]);
+void EEVEE_sample_rectangle(int sample_ofs,
+ const float x_axis[3],
+ const float y_axis[3],
+ float size_x,
+ float size_y,
+ float rsample[3]);
+void EEVEE_sample_ellipse(int sample_ofs,
+ const float x_axis[3],
+ const float y_axis[3],
+ float size_x,
+ float size_y,
+ float rsample[3]);
+void EEVEE_random_rotation_m4(int sample_ofs, float scale, float r_mat[4][4]);
/* eevee_shaders.c */
void EEVEE_shaders_lightprobe_shaders_init(void);
@@ -1044,6 +1008,11 @@ void EEVEE_subsurface_add_pass(EEVEE_ViewLayerData *sldata,
EEVEE_Data *vedata,
uint sss_id,
struct GPUUniformBuffer *sss_profile);
+void EEVEE_subsurface_translucency_add_pass(EEVEE_ViewLayerData *sldata,
+ EEVEE_Data *vedata,
+ uint sss_id,
+ struct GPUUniformBuffer *sss_profile,
+ struct GPUTexture *sss_tex_profile);
void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_subsurface_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_subsurface_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);