Compare commits
42 Commits
xr-world-n
...
tmp-eevee-
Author | SHA1 | Date | |
---|---|---|---|
7499e7912e | |||
b2320263f2 | |||
c11aea538f | |||
3b86d5e95c | |||
ca22d1ec79 | |||
9f8c22929b | |||
5ead114e1c | |||
8197022d6c | |||
6e18b02065 | |||
cf6ee13fab | |||
4f89f4e1b0 | |||
2ef54d03b5 | |||
4090f06b2d | |||
4d05823055 | |||
5ce4ce2e50 | |||
bd80c21635 | |||
![]() |
b7386c66f9 | ||
ada03e8673 | |||
0909b564a9 | |||
c233271b0b | |||
97f50c71b9 | |||
fc4f2571ba | |||
a260d1cd69 | |||
16b9841fc1 | |||
236794d07a | |||
![]() |
7965c735f1 | ||
![]() |
c9360b239b | ||
08ac4d3d71 | |||
36d9f7e375 | |||
![]() |
eb23b39b7f | ||
![]() |
80fffba132 | ||
a88316b4a6 | |||
![]() |
7d38f50367 | ||
975c45df9a | |||
![]() |
f17e7e0b62 | ||
b0686af32b | |||
5d2e54af37 | |||
21e5a72798 | |||
13769bcbe5 | |||
9ebb3a386e | |||
fee46615f4 | |||
e22ea3dc0e |
@@ -494,16 +494,18 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CUDA
|
||||
if (mask & DEVICE_MASK_CUDA) {
|
||||
#if defined(WITH_CUDA) || defined(WITH_OPTIX)
|
||||
if (mask & (DEVICE_MASK_CUDA | DEVICE_MASK_OPTIX)) {
|
||||
if (!(devices_initialized_mask & DEVICE_MASK_CUDA)) {
|
||||
if (device_cuda_init()) {
|
||||
device_cuda_info(cuda_devices);
|
||||
}
|
||||
devices_initialized_mask |= DEVICE_MASK_CUDA;
|
||||
}
|
||||
foreach (DeviceInfo &info, cuda_devices) {
|
||||
devices.push_back(info);
|
||||
if (mask & DEVICE_MASK_CUDA) {
|
||||
foreach (DeviceInfo &info, cuda_devices) {
|
||||
devices.push_back(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -512,7 +514,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
||||
if (mask & DEVICE_MASK_OPTIX) {
|
||||
if (!(devices_initialized_mask & DEVICE_MASK_OPTIX)) {
|
||||
if (device_optix_init()) {
|
||||
device_optix_info(optix_devices);
|
||||
device_optix_info(cuda_devices, optix_devices);
|
||||
}
|
||||
devices_initialized_mask |= DEVICE_MASK_OPTIX;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ Device *device_multi_create(DeviceInfo &info, Stats &stats, Profiler &profiler,
|
||||
void device_cpu_info(vector<DeviceInfo> &devices);
|
||||
void device_opencl_info(vector<DeviceInfo> &devices);
|
||||
void device_cuda_info(vector<DeviceInfo> &devices);
|
||||
void device_optix_info(vector<DeviceInfo> &devices);
|
||||
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices);
|
||||
void device_network_info(vector<DeviceInfo> &devices);
|
||||
|
||||
string device_cpu_capabilities();
|
||||
|
@@ -1534,14 +1534,11 @@ bool device_optix_init()
|
||||
return true;
|
||||
}
|
||||
|
||||
void device_optix_info(vector<DeviceInfo> &devices)
|
||||
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices)
|
||||
{
|
||||
// Simply add all supported CUDA devices as OptiX devices again
|
||||
vector<DeviceInfo> cuda_devices;
|
||||
device_cuda_info(cuda_devices);
|
||||
|
||||
for (auto it = cuda_devices.begin(); it != cuda_devices.end();) {
|
||||
DeviceInfo &info = *it;
|
||||
for (const DeviceInfo &cuda_info : cuda_devices) {
|
||||
DeviceInfo info = cuda_info;
|
||||
assert(info.type == DEVICE_CUDA);
|
||||
info.type = DEVICE_OPTIX;
|
||||
info.id += "_OptiX";
|
||||
@@ -1564,13 +1561,10 @@ void device_optix_info(vector<DeviceInfo> &devices)
|
||||
}
|
||||
|
||||
// Only add devices with RTX support
|
||||
if (rtcore_version == 0 && !getenv("CYCLES_OPTIX_TEST"))
|
||||
it = cuda_devices.erase(it);
|
||||
else
|
||||
++it;
|
||||
if (rtcore_version != 0 || getenv("CYCLES_OPTIX_TEST")) {
|
||||
devices.push_back(info);
|
||||
}
|
||||
}
|
||||
|
||||
devices.insert(devices.end(), cuda_devices.begin(), cuda_devices.end());
|
||||
}
|
||||
|
||||
Device *device_optix_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)
|
||||
|
@@ -21,24 +21,24 @@
|
||||
#include "../MEM_guardedalloc.h"
|
||||
#include <new>
|
||||
|
||||
void *operator new(size_t size, const char *str) throw(std::bad_alloc);
|
||||
void *operator new[](size_t size, const char *str) throw(std::bad_alloc);
|
||||
void *operator new(size_t size, const char *str);
|
||||
void *operator new[](size_t size, const char *str);
|
||||
|
||||
/* not default but can be used when needing to set a string */
|
||||
void *operator new(size_t size, const char *str) throw(std::bad_alloc)
|
||||
void *operator new(size_t size, const char *str)
|
||||
{
|
||||
return MEM_mallocN(size, str);
|
||||
}
|
||||
void *operator new[](size_t size, const char *str) throw(std::bad_alloc)
|
||||
void *operator new[](size_t size, const char *str)
|
||||
{
|
||||
return MEM_mallocN(size, str);
|
||||
}
|
||||
|
||||
void *operator new(size_t size) throw(std::bad_alloc)
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return MEM_mallocN(size, "C++/anonymous");
|
||||
}
|
||||
void *operator new[](size_t size) throw(std::bad_alloc)
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return MEM_mallocN(size, "C++/anonymous[]");
|
||||
}
|
||||
|
Submodule release/datafiles/locale updated: 80f390fd0e...1d9b8b2ffa
Binary file not shown.
Before Width: | Height: | Size: 731 KiB After Width: | Height: | Size: 721 KiB |
Submodule release/scripts/addons updated: 44c17b0116...47a32a5370
@@ -123,7 +123,7 @@ class PHYSICS_PT_field_settings(PhysicButtonsPanel, Panel):
|
||||
col.prop(field, "use_object_coords")
|
||||
col.prop(field, "use_2d_force")
|
||||
|
||||
elif field.type == 'SMOKE_FLOW':
|
||||
elif field.type == 'FLUID_FLOW':
|
||||
col = flow.column()
|
||||
col.prop(field, "strength")
|
||||
col.prop(field, "flow")
|
||||
|
@@ -191,7 +191,6 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
|
||||
/* Drawing */
|
||||
|
||||
void BKE_pbvh_draw_cb(PBVH *bvh,
|
||||
bool show_vcol,
|
||||
bool update_only_visible,
|
||||
PBVHFrustumPlanes *update_frustum,
|
||||
PBVHFrustumPlanes *draw_frustum,
|
||||
|
@@ -113,7 +113,7 @@ PartDeflect *BKE_partdeflect_new(int type)
|
||||
case PFIELD_TEXTURE:
|
||||
pd->f_size = 1.0f;
|
||||
break;
|
||||
case PFIELD_SMOKEFLOW:
|
||||
case PFIELD_FLUIDFLOW:
|
||||
pd->f_flow = 1.0f;
|
||||
break;
|
||||
}
|
||||
@@ -1024,7 +1024,7 @@ static void do_physical_effector(EffectorCache *eff,
|
||||
|
||||
mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
|
||||
break;
|
||||
case PFIELD_SMOKEFLOW:
|
||||
case PFIELD_FLUIDFLOW:
|
||||
zero_v3(force);
|
||||
#ifdef WITH_FLUID
|
||||
if (pd->f_source) {
|
||||
@@ -1046,7 +1046,7 @@ static void do_physical_effector(EffectorCache *eff,
|
||||
if (pd->flag & PFIELD_DO_LOCATION) {
|
||||
madd_v3_v3fl(total_force, force, 1.0f / point->vel_to_sec);
|
||||
|
||||
if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_SMOKEFLOW) == 0 &&
|
||||
if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_FLUIDFLOW) == 0 &&
|
||||
pd->f_flow != 0.0f) {
|
||||
madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);
|
||||
}
|
||||
|
@@ -3196,7 +3196,7 @@ static void update_effectors(
|
||||
{
|
||||
ListBase *effectors;
|
||||
/* make sure smoke flow influence is 0.0f */
|
||||
mds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
|
||||
mds->effector_weights->weight[PFIELD_FLUIDFLOW] = 0.0f;
|
||||
effectors = BKE_effectors_create(depsgraph, ob, NULL, mds->effector_weights);
|
||||
|
||||
if (effectors) {
|
||||
|
@@ -1009,7 +1009,6 @@ typedef struct PBVHUpdateData {
|
||||
|
||||
float (*vnors)[3];
|
||||
int flag;
|
||||
bool show_vcol;
|
||||
bool show_sculpt_face_sets;
|
||||
} PBVHUpdateData;
|
||||
|
||||
@@ -1250,12 +1249,10 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
|
||||
BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings);
|
||||
}
|
||||
|
||||
static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol)
|
||||
static int pbvh_get_buffers_update_flags(PBVH *UNUSED(bvh))
|
||||
{
|
||||
int update_flags = 0;
|
||||
update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0;
|
||||
update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0;
|
||||
update_flags |= bvh->show_face_sets ? GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS : 0;
|
||||
int update_flags = GPU_PBVH_BUFFERS_SHOW_VCOL | GPU_PBVH_BUFFERS_SHOW_MASK |
|
||||
GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS;
|
||||
return update_flags;
|
||||
}
|
||||
|
||||
@@ -1295,7 +1292,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
|
||||
}
|
||||
|
||||
if (node->flag & PBVH_UpdateDrawBuffers) {
|
||||
const int update_flags = pbvh_get_buffers_update_flags(bvh, data->show_vcol);
|
||||
const int update_flags = pbvh_get_buffers_update_flags(bvh);
|
||||
switch (bvh->type) {
|
||||
case PBVH_GRIDS:
|
||||
GPU_pbvh_grid_buffers_update(node->draw_buffers,
|
||||
@@ -1335,8 +1332,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
|
||||
}
|
||||
}
|
||||
|
||||
static void pbvh_update_draw_buffers(
|
||||
PBVH *bvh, PBVHNode **nodes, int totnode, bool show_vcol, int update_flag)
|
||||
static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, int update_flag)
|
||||
{
|
||||
if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(bvh->type, PBVH_GRIDS, PBVH_BMESH)) {
|
||||
/* Free buffers uses OpenGL, so not in parallel. */
|
||||
@@ -1362,7 +1358,6 @@ static void pbvh_update_draw_buffers(
|
||||
PBVHUpdateData data = {
|
||||
.bvh = bvh,
|
||||
.nodes = nodes,
|
||||
.show_vcol = show_vcol,
|
||||
};
|
||||
|
||||
TaskParallelSettings settings;
|
||||
@@ -2679,7 +2674,6 @@ static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v)
|
||||
}
|
||||
|
||||
void BKE_pbvh_draw_cb(PBVH *bvh,
|
||||
bool show_vcol,
|
||||
bool update_only_visible,
|
||||
PBVHFrustumPlanes *update_frustum,
|
||||
PBVHFrustumPlanes *draw_frustum,
|
||||
@@ -2696,7 +2690,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
|
||||
BKE_pbvh_search_gather(bvh, update_search_cb, POINTER_FROM_INT(update_flag), &nodes, &totnode);
|
||||
|
||||
if (totnode) {
|
||||
pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol, update_flag);
|
||||
pbvh_update_draw_buffers(bvh, nodes, totnode, update_flag);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(nodes);
|
||||
@@ -2708,7 +2702,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
|
||||
|
||||
if (update_only_visible && (data.accum_update_flag & update_flag)) {
|
||||
/* Update draw buffers in visible nodes. */
|
||||
pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol, data.accum_update_flag);
|
||||
pbvh_update_draw_buffers(bvh, nodes, totnode, data.accum_update_flag);
|
||||
}
|
||||
|
||||
/* Draw. */
|
||||
|
@@ -114,7 +114,7 @@ class Task {
|
||||
/* Execute task. */
|
||||
void operator()() const
|
||||
{
|
||||
run(pool, taskdata);
|
||||
tbb::this_task_arena::isolate([this] { run(pool, taskdata); });
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -89,11 +89,13 @@ struct RangeTask {
|
||||
|
||||
void operator()(const tbb::blocked_range<int> &r) const
|
||||
{
|
||||
TaskParallelTLS tls;
|
||||
tls.userdata_chunk = userdata_chunk;
|
||||
for (int i = r.begin(); i != r.end(); ++i) {
|
||||
func(userdata, i, &tls);
|
||||
}
|
||||
tbb::this_task_arena::isolate([this, r] {
|
||||
TaskParallelTLS tls;
|
||||
tls.userdata_chunk = userdata_chunk;
|
||||
for (int i = r.begin(); i != r.end(); ++i) {
|
||||
func(userdata, i, &tls);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void join(const RangeTask &other)
|
||||
|
@@ -4786,15 +4786,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
brush->gpencil_weight_tool = brush->gpencil_settings->brush_type;
|
||||
}
|
||||
}
|
||||
/* Tint brush. */
|
||||
Brush *brush = BLI_findstring(&bmain->brushes, "Tint", offsetof(ID, name) + 2);
|
||||
if (brush == NULL) {
|
||||
brush = BKE_brush_add(bmain, "Tint", OB_MODE_PAINT_GPENCIL);
|
||||
BKE_brush_init_gpencil_settings(brush);
|
||||
}
|
||||
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TINT);
|
||||
|
||||
BKE_paint_toolslots_init_from_main(bmain);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (Material *, mat, &bmain->materials) {
|
||||
|
@@ -231,19 +231,17 @@ static void blo_update_defaults_screen(bScreen *screen,
|
||||
/* 2D animation template. */
|
||||
if (app_template && STREQ(app_template, "2D_Animation")) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
if (area->spacetype == SPACE_ACTION) {
|
||||
SpaceAction *saction = area->spacedata.first;
|
||||
/* Enable Sliders. */
|
||||
saction->flag |= SACTION_SLIDERS;
|
||||
}
|
||||
else if (area->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = area->spacedata.first;
|
||||
/* Set Material Color by default. */
|
||||
v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
|
||||
/* Enable Annotations. */
|
||||
v3d->flag2 |= V3D_SHOW_ANNOTATION;
|
||||
}
|
||||
if (area->spacetype == SPACE_ACTION) {
|
||||
SpaceAction *saction = area->spacedata.first;
|
||||
/* Enable Sliders. */
|
||||
saction->flag |= SACTION_SLIDERS;
|
||||
}
|
||||
else if (area->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = area->spacedata.first;
|
||||
/* Set Material Color by default. */
|
||||
v3d->shading.color_type = V3D_SHADING_MATERIAL_COLOR;
|
||||
/* Enable Annotations. */
|
||||
v3d->flag2 |= V3D_SHOW_ANNOTATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -433,7 +433,7 @@ void DepsgraphRelationBuilder::add_particle_forcefield_relations(const Operation
|
||||
}
|
||||
|
||||
/* Smoke flow relations. */
|
||||
if (relation->pd->forcefield == PFIELD_SMOKEFLOW && relation->pd->f_source) {
|
||||
if (relation->pd->forcefield == PFIELD_FLUIDFLOW && relation->pd->f_source) {
|
||||
ComponentKey trf_key(&relation->pd->f_source->id, NodeType::TRANSFORM);
|
||||
add_relation(trf_key, key, "Smoke Force Domain");
|
||||
ComponentKey eff_key(&relation->pd->f_source->id, NodeType::GEOMETRY);
|
||||
|
@@ -141,11 +141,11 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle,
|
||||
}
|
||||
|
||||
/* Smoke flow relations. */
|
||||
if (relation->pd->forcefield == PFIELD_SMOKEFLOW && relation->pd->f_source != nullptr) {
|
||||
if (relation->pd->forcefield == PFIELD_FLUIDFLOW && relation->pd->f_source != nullptr) {
|
||||
DEG_add_object_pointcache_relation(
|
||||
handle, relation->pd->f_source, DEG_OB_COMP_TRANSFORM, "Smoke Force Domain");
|
||||
handle, relation->pd->f_source, DEG_OB_COMP_TRANSFORM, "Fluid Force Domain");
|
||||
DEG_add_object_pointcache_relation(
|
||||
handle, relation->pd->f_source, DEG_OB_COMP_GEOMETRY, "Smoke Force Domain");
|
||||
handle, relation->pd->f_source, DEG_OB_COMP_GEOMETRY, "Fluid Force Domain");
|
||||
}
|
||||
|
||||
/* Absorption forces need collision relation. */
|
||||
|
@@ -34,6 +34,7 @@ set(INC
|
||||
../imbuf
|
||||
../makesdna
|
||||
../makesrna
|
||||
../nodes
|
||||
../render/extern/include
|
||||
../render/intern/include
|
||||
../windowmanager
|
||||
|
@@ -202,7 +202,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
|
||||
stl->g_data->depth_shgrp[do_in_front];
|
||||
|
||||
if (use_sculpt_pbvh) {
|
||||
DRW_shgroup_call_sculpt(shgrp, ob, false, false, false);
|
||||
DRW_shgroup_call_sculpt(shgrp, ob, false, false);
|
||||
}
|
||||
else {
|
||||
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
|
||||
|
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "BLI_memblock.h"
|
||||
|
||||
#include "eevee_lightcache.h"
|
||||
#include "eevee_private.h"
|
||||
|
||||
@@ -54,8 +56,17 @@ void EEVEE_view_layer_data_free(void *storage)
|
||||
DRW_UBO_FREE_SAFE(sldata->grid_ubo);
|
||||
DRW_UBO_FREE_SAFE(sldata->planar_ubo);
|
||||
DRW_UBO_FREE_SAFE(sldata->common_ubo);
|
||||
for (int i = 0; i < MAX_MATERIAL_RENDER_PASSES_UBO; i++) {
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo[i]);
|
||||
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.combined);
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.diff_color);
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.diff_light);
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.spec_color);
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.spec_light);
|
||||
DRW_UBO_FREE_SAFE(sldata->renderpass_ubo.emit);
|
||||
|
||||
if (sldata->material_cache) {
|
||||
BLI_memblock_destroy(sldata->material_cache, NULL);
|
||||
sldata->material_cache = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -333,8 +333,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
grp = DRW_shgroup_create(EEVEE_shaders_velocity_resolve_sh_get(), psl->velocity_resolve);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data.depth_src);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_mat4(grp, "currPersinv", effects->velocity_curr_persinv);
|
||||
DRW_shgroup_uniform_mat4(grp, "pastPersmat", effects->velocity_past_persmat);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
|
@@ -88,7 +88,7 @@ static void eevee_engine_init(void *ved)
|
||||
* `EEVEE_effects_init` needs to go second for TAA. */
|
||||
EEVEE_renderpasses_init(vedata);
|
||||
EEVEE_effects_init(sldata, vedata, camera, false);
|
||||
EEVEE_materials_init(sldata, stl, fbl);
|
||||
EEVEE_materials_init(sldata, vedata, stl, fbl);
|
||||
EEVEE_shadows_init(sldata);
|
||||
EEVEE_lightprobes_init(sldata, vedata);
|
||||
}
|
||||
@@ -230,7 +230,7 @@ static void eevee_draw_scene(void *vedata)
|
||||
BLI_halton_3d(primes, offset, samp, r);
|
||||
EEVEE_update_noise(psl, fbl, r);
|
||||
EEVEE_volumes_set_jitter(sldata, samp - 1);
|
||||
EEVEE_materials_init(sldata, stl, fbl);
|
||||
EEVEE_materials_init(sldata, vedata, stl, fbl);
|
||||
}
|
||||
/* Copy previous persmat to UBO data */
|
||||
copy_m4_m4(sldata->common_data.prev_persmat, stl->effects->prev_persmat);
|
||||
@@ -274,8 +274,7 @@ static void eevee_draw_scene(void *vedata)
|
||||
|
||||
/* Depth prepass */
|
||||
DRW_stats_group_start("Prepass");
|
||||
DRW_draw_pass(psl->depth_pass);
|
||||
DRW_draw_pass(psl->depth_pass_cull);
|
||||
DRW_draw_pass(psl->depth_ps);
|
||||
DRW_stats_group_end();
|
||||
|
||||
/* Create minmax texture */
|
||||
@@ -289,9 +288,9 @@ static void eevee_draw_scene(void *vedata)
|
||||
/* Shading pass */
|
||||
DRW_stats_group_start("Shading");
|
||||
if (DRW_state_draw_background()) {
|
||||
DRW_draw_pass(psl->background_pass);
|
||||
DRW_draw_pass(psl->background_ps);
|
||||
}
|
||||
EEVEE_materials_draw_opaque(sldata, psl);
|
||||
DRW_draw_pass(psl->material_ps);
|
||||
EEVEE_subsurface_data_render(sldata, vedata);
|
||||
DRW_stats_group_end();
|
||||
|
||||
@@ -306,9 +305,8 @@ static void eevee_draw_scene(void *vedata)
|
||||
|
||||
/* Opaque refraction */
|
||||
DRW_stats_group_start("Opaque Refraction");
|
||||
DRW_draw_pass(psl->refract_depth_pass);
|
||||
DRW_draw_pass(psl->refract_depth_pass_cull);
|
||||
DRW_draw_pass(psl->refract_pass);
|
||||
DRW_draw_pass(psl->depth_refract_ps);
|
||||
DRW_draw_pass(psl->material_refract_ps);
|
||||
DRW_stats_group_end();
|
||||
|
||||
/* Volumetrics Resolve Opaque */
|
||||
|
@@ -822,7 +822,7 @@ static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lb
|
||||
DRW_render_viewport_size_set(viewport_size);
|
||||
|
||||
EEVEE_effects_init(sldata, vedata, NULL, true);
|
||||
EEVEE_materials_init(sldata, stl, fbl);
|
||||
EEVEE_materials_init(sldata, vedata, stl, fbl);
|
||||
EEVEE_shadows_init(sldata);
|
||||
EEVEE_lightprobes_init(sldata, vedata);
|
||||
|
||||
|
@@ -248,8 +248,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata,
|
||||
// DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
|
||||
DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call_instances(grp, NULL, geom, 6);
|
||||
@@ -271,8 +270,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata,
|
||||
DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1);
|
||||
DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
@@ -293,8 +291,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata,
|
||||
DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
|
||||
DRW_shgroup_uniform_texture(grp, "probeDepth", rt_depth);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
@@ -337,51 +334,29 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
Scene *scene = draw_ctx->scene;
|
||||
World *wo = scene->world;
|
||||
|
||||
const float *col = G_draw.block.colorBackground;
|
||||
|
||||
/* LookDev */
|
||||
EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->probe_background, wo, pinfo);
|
||||
/* END */
|
||||
|
||||
if (!grp && wo) {
|
||||
col = &wo->horr;
|
||||
struct GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, NULL, wo, VAR_WORLD_PROBE);
|
||||
|
||||
if (wo->use_nodes && wo->nodetree) {
|
||||
static float error_col[3] = {1.0f, 0.0f, 1.0f};
|
||||
static float queue_col[3] = {0.5f, 0.5f, 0.5f};
|
||||
struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo);
|
||||
|
||||
eGPUMaterialStatus status = GPU_material_status(gpumat);
|
||||
|
||||
switch (status) {
|
||||
case GPU_MAT_SUCCESS:
|
||||
grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
|
||||
DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
|
||||
/* TODO (fclem): remove those (need to clean the GLSL files). */
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
break;
|
||||
case GPU_MAT_QUEUED:
|
||||
stl->g_data->queued_shaders_count++;
|
||||
col = queue_col;
|
||||
break;
|
||||
default:
|
||||
col = error_col;
|
||||
break;
|
||||
}
|
||||
}
|
||||
grp = DRW_shgroup_material_create(gpumat, psl->probe_background);
|
||||
DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
|
||||
/* TODO (fclem): remove those (need to clean the GLSL files). */
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
}
|
||||
|
||||
/* Fallback if shader fails or if not using nodetree. */
|
||||
if (grp == NULL) {
|
||||
grp = DRW_shgroup_create(EEVEE_shaders_probe_default_sh_get(), psl->probe_background);
|
||||
DRW_shgroup_uniform_vec3(grp, "color", col, 1);
|
||||
DRW_shgroup_uniform_vec3(grp, "color", G_draw.block.colorBackground, 1);
|
||||
DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
}
|
||||
@@ -408,8 +383,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
/* TODO (fclem) get rid of those UBO. */
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, cube_len * 2);
|
||||
}
|
||||
@@ -436,8 +410,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
DRW_shgroup_uniform_block(shgrp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(shgrp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
shgrp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(shgrp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
int tri_count = egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2] * 2;
|
||||
DRW_shgroup_call_procedural_triangles(shgrp, NULL, tri_count);
|
||||
}
|
||||
@@ -455,8 +428,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(EEVEE_shaders_probe_planar_display_sh_get(),
|
||||
psl->probe_display);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "probePlanars", &txl->planar_pool);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
stl->g_data->planar_display_shgrp = DRW_shgroup_call_buffer_instance(
|
||||
grp, e_data.format_probe_display_planar, DRW_cache_quad_get());
|
||||
@@ -923,12 +895,10 @@ static void lightbake_render_scene_face(int face, EEVEE_BakeRenderData *user_dat
|
||||
GPU_framebuffer_bind(face_fb[face]);
|
||||
GPU_framebuffer_clear_depth(face_fb[face], 1.0f);
|
||||
|
||||
DRW_draw_pass(psl->depth_pass);
|
||||
DRW_draw_pass(psl->depth_pass_cull);
|
||||
DRW_draw_pass(psl->depth_ps);
|
||||
DRW_draw_pass(psl->probe_background);
|
||||
EEVEE_materials_draw_opaque(sldata, psl);
|
||||
DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
|
||||
DRW_draw_pass(psl->sss_pass_cull);
|
||||
DRW_draw_pass(psl->material_ps);
|
||||
DRW_draw_pass(psl->material_sss_ps); /* Only output standard pass */
|
||||
DRW_draw_pass(psl->transparent_pass);
|
||||
}
|
||||
|
||||
@@ -987,10 +957,8 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
|
||||
/* Slight modification: we handle refraction as normal
|
||||
* shading and don't do SSRefraction. */
|
||||
|
||||
DRW_draw_pass(psl->depth_pass_clip);
|
||||
DRW_draw_pass(psl->depth_pass_clip_cull);
|
||||
DRW_draw_pass(psl->refract_depth_pass_clip);
|
||||
DRW_draw_pass(psl->refract_depth_pass_clip_cull);
|
||||
DRW_draw_pass(psl->depth_ps);
|
||||
DRW_draw_pass(psl->depth_refract_ps);
|
||||
|
||||
DRW_draw_pass(psl->probe_background);
|
||||
EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer);
|
||||
@@ -999,10 +967,9 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
|
||||
GPU_framebuffer_bind(fbl->planarref_fb);
|
||||
|
||||
/* Shading pass */
|
||||
EEVEE_materials_draw_opaque(sldata, psl);
|
||||
DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
|
||||
DRW_draw_pass(psl->sss_pass_cull);
|
||||
DRW_draw_pass(psl->refract_pass);
|
||||
DRW_draw_pass(psl->material_ps);
|
||||
DRW_draw_pass(psl->material_sss_ps); /* Only output standard pass */
|
||||
DRW_draw_pass(psl->material_refract_ps);
|
||||
|
||||
/* Transparent */
|
||||
if (DRW_state_is_image_render()) {
|
||||
|
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "GPU_material.h"
|
||||
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "eevee_lightcache.h"
|
||||
@@ -56,6 +58,43 @@ static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
|
||||
g_data->studiolight_rot_z = 0.0f;
|
||||
}
|
||||
|
||||
static void eevee_lookdev_hdri_preview_init(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata)
|
||||
{
|
||||
EEVEE_PassList *psl = vedata->psl;
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
DRWShadingGroup *grp;
|
||||
|
||||
struct GPUBatch *sphere = DRW_cache_sphere_get();
|
||||
int mat_options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
|
||||
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
|
||||
DRW_STATE_CULL_BACK;
|
||||
|
||||
{
|
||||
Material *ma = EEVEE_material_default_diffuse_get();
|
||||
GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, ma, NULL, mat_options);
|
||||
struct GPUShader *sh = GPU_material_get_shader(gpumat);
|
||||
|
||||
DRW_PASS_CREATE(psl->lookdev_diffuse_pass, state);
|
||||
grp = DRW_shgroup_create(sh, psl->lookdev_diffuse_pass);
|
||||
EEVEE_material_bind_resources(grp, gpumat, sldata, vedata, NULL, NULL, false, false);
|
||||
DRW_shgroup_add_material_resources(grp, gpumat);
|
||||
DRW_shgroup_call(grp, sphere, NULL);
|
||||
}
|
||||
{
|
||||
Material *ma = EEVEE_material_default_glossy_get();
|
||||
GPUMaterial *gpumat = EEVEE_material_get(vedata, scene, ma, NULL, mat_options);
|
||||
struct GPUShader *sh = GPU_material_get_shader(gpumat);
|
||||
|
||||
DRW_PASS_CREATE(psl->lookdev_glossy_pass, state);
|
||||
grp = DRW_shgroup_create(sh, psl->lookdev_glossy_pass);
|
||||
EEVEE_material_bind_resources(grp, gpumat, sldata, vedata, NULL, NULL, false, false);
|
||||
DRW_shgroup_add_material_resources(grp, gpumat);
|
||||
DRW_shgroup_call(grp, sphere, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
|
||||
EEVEE_ViewLayerData *sldata,
|
||||
DRWShadingGroup **r_grp,
|
||||
@@ -106,6 +145,8 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
|
||||
effects->anchor[1] = rect->ymin;
|
||||
EEVEE_temporal_sampling_reset(vedata);
|
||||
}
|
||||
|
||||
eevee_lookdev_hdri_preview_init(vedata, sldata);
|
||||
}
|
||||
|
||||
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
|
||||
@@ -176,8 +217,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
}
|
||||
|
||||
DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
|
||||
|
198
source/blender/draw/engines/eevee/eevee_lut_gen.c
Normal file
198
source/blender/draw/engines/eevee/eevee_lut_gen.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright 2020, Blender Foundation.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup draw_engine
|
||||
*
|
||||
* EEVEE LUT generation:
|
||||
*
|
||||
* Routine to generate the LUT used by eevee stored in eevee_lut.h
|
||||
* Theses functions are not to be used in the final executable.
|
||||
*/
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_string_utils.h"
|
||||
|
||||
extern char datatoc_bsdf_lut_frag_glsl[];
|
||||
extern char datatoc_btdf_lut_frag_glsl[];
|
||||
extern char datatoc_bsdf_common_lib_glsl[];
|
||||
extern char datatoc_bsdf_sampling_lib_glsl[];
|
||||
extern char datatoc_lightprobe_geom_glsl[];
|
||||
extern char datatoc_lightprobe_vert_glsl[];
|
||||
|
||||
static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
|
||||
{
|
||||
struct GPUTexture *tex;
|
||||
struct GPUFrameBuffer *fb = NULL;
|
||||
static float samples_len = 8192.0f;
|
||||
static float inv_samples_len = 1.0f / 8192.0f;
|
||||
|
||||
char *lib_str = BLI_string_joinN(datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl);
|
||||
|
||||
struct GPUShader *sh = DRW_shader_create_with_lib(datatoc_lightprobe_vert_glsl,
|
||||
datatoc_lightprobe_geom_glsl,
|
||||
datatoc_bsdf_lut_frag_glsl,
|
||||
lib_str,
|
||||
"#define HAMMERSLEY_SIZE 8192\n"
|
||||
"#define BRDF_LUT_SIZE 64\n"
|
||||
"#define NOISE_SIZE 64\n");
|
||||
|
||||
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
|
||||
DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1);
|
||||
DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1);
|
||||
DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley);
|
||||
DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter);
|
||||
|
||||
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
|
||||
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
|
||||
|
||||
tex = DRW_texture_create_2d(w, h, GPU_RG16F, DRW_TEX_FILTER, (float *)texels);
|
||||
|
||||
DRWFboTexture tex_filter = {&tex, GPU_RG16F, DRW_TEX_FILTER};
|
||||
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
|
||||
|
||||
GPU_framebuffer_bind(fb);
|
||||
DRW_draw_pass(pass);
|
||||
|
||||
float *data = MEM_mallocN(sizeof(float[3]) * w * h, "lut");
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadPixels(0, 0, w, h, GL_RGB, GL_FLOAT, data);
|
||||
|
||||
printf("{");
|
||||
for (int i = 0; i < w * h * 3; i += 3) {
|
||||
printf("%ff, %ff, ", data[i], data[i + 1]);
|
||||
i += 3;
|
||||
printf("%ff, %ff, ", data[i], data[i + 1]);
|
||||
i += 3;
|
||||
printf("%ff, %ff, ", data[i], data[i + 1]);
|
||||
i += 3;
|
||||
printf("%ff, %ff, \n", data[i], data[i + 1]);
|
||||
}
|
||||
printf("}");
|
||||
|
||||
MEM_freeN(texels);
|
||||
MEM_freeN(data);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
|
||||
{
|
||||
struct GPUTexture *tex;
|
||||
struct GPUTexture *hammersley = create_hammersley_sample_texture(8192);
|
||||
struct GPUFrameBuffer *fb = NULL;
|
||||
static float samples_len = 8192.0f;
|
||||
static float a2 = 0.0f;
|
||||
static float inv_samples_len = 1.0f / 8192.0f;
|
||||
|
||||
char *frag_str = BLI_string_joinN(
|
||||
datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl, datatoc_btdf_lut_frag_glsl);
|
||||
|
||||
struct GPUShader *sh = DRW_shader_create_fullscreen(frag_str,
|
||||
"#define HAMMERSLEY_SIZE 8192\n"
|
||||
"#define BRDF_LUT_SIZE 64\n"
|
||||
"#define NOISE_SIZE 64\n"
|
||||
"#define LUT_SIZE 64\n");
|
||||
|
||||
MEM_freeN(frag_str);
|
||||
|
||||
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
|
||||
DRW_shgroup_uniform_float(grp, "a2", &a2, 1);
|
||||
DRW_shgroup_uniform_float(grp, "sampleCount", &samples_len, 1);
|
||||
DRW_shgroup_uniform_float(grp, "invSampleCount", &inv_samples_len, 1);
|
||||
DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex);
|
||||
|
||||
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call(grp, geom, NULL);
|
||||
|
||||
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
|
||||
|
||||
tex = DRW_texture_create_2d(w, h, GPU_R16F, DRW_TEX_FILTER, (float *)texels);
|
||||
|
||||
DRWFboTexture tex_filter = {&tex, GPU_R16F, DRW_TEX_FILTER};
|
||||
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
|
||||
|
||||
GPU_framebuffer_bind(fb);
|
||||
|
||||
float *data = MEM_mallocN(sizeof(float[3]) * w * h, "lut");
|
||||
|
||||
float inc = 1.0f / 31.0f;
|
||||
float roughness = 1e-8f - inc;
|
||||
FILE *f = BLI_fopen("btdf_split_sum_ggx.h", "w");
|
||||
fprintf(f, "static float btdf_split_sum_ggx[32][64 * 64] = {\n");
|
||||
do {
|
||||
roughness += inc;
|
||||
CLAMP(roughness, 1e-4f, 1.0f);
|
||||
a2 = powf(roughness, 4.0f);
|
||||
DRW_draw_pass(pass);
|
||||
|
||||
GPU_framebuffer_read_data(0, 0, w, h, 3, 0, data);
|
||||
|
||||
#if 1
|
||||
fprintf(f, "\t{\n\t\t");
|
||||
for (int i = 0; i < w * h * 3; i += 3) {
|
||||
fprintf(f, "%ff,", data[i]);
|
||||
if (((i / 3) + 1) % 12 == 0) {
|
||||
fprintf(f, "\n\t\t");
|
||||
}
|
||||
else {
|
||||
fprintf(f, " ");
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n\t},\n");
|
||||
#else
|
||||
for (int i = 0; i < w * h * 3; i += 3) {
|
||||
if (data[i] < 0.01) {
|
||||
printf(" ");
|
||||
}
|
||||
else if (data[i] < 0.3) {
|
||||
printf(".");
|
||||
}
|
||||
else if (data[i] < 0.6) {
|
||||
printf("+");
|
||||
}
|
||||
else if (data[i] < 0.9) {
|
||||
printf("%%");
|
||||
}
|
||||
else {
|
||||
printf("#");
|
||||
}
|
||||
if ((i / 3 + 1) % 64 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} while (roughness < 1.0f);
|
||||
fprintf(f, "\n};\n");
|
||||
|
||||
fclose(f);
|
||||
|
||||
MEM_freeN(texels);
|
||||
MEM_freeN(data);
|
||||
|
||||
return tex;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -114,8 +114,7 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.mist_sh, psl->mist_accum_ps);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_vec3(grp, "mistSettings", &g_data->mist_start, 1);
|
||||
DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
|
||||
}
|
||||
|
@@ -170,8 +170,7 @@ void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata
|
||||
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &effects->ssr_normal_input);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "horizonBuffer", &effects->gtao_horizons);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
|
||||
}
|
||||
else {
|
||||
@@ -209,8 +208,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_texture_ref(grp, "maxzBuffer", &txl->maxzbuffer);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &effects->ao_src_depth);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
|
||||
DRW_PASS_CREATE(psl->ao_horizon_search_layer, DRW_STATE_WRITE_COLOR);
|
||||
@@ -219,8 +217,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_texture_ref(grp, "maxzBuffer", &txl->maxzbuffer);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBufferLayered", &effects->ao_src_depth);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_int(grp, "layer", &stl->effects->ao_depth_layer, 1);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
|
||||
@@ -233,8 +230,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_texture_ref(grp, "normalBuffer", &effects->ssr_normal_input);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "horizonBuffer", &effects->gtao_horizons);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
}
|
||||
}
|
||||
|
@@ -158,35 +158,23 @@ BLI_INLINE bool eevee_hdri_preview_overlay_enabled(const View3D *v3d)
|
||||
(EEVEE_RENDER_PASS_EMIT | EEVEE_RENDER_PASS_DIFFUSE_COLOR | EEVEE_RENDER_PASS_DIFFUSE_LIGHT | \
|
||||
EEVEE_RENDER_PASS_SPECULAR_COLOR | EEVEE_RENDER_PASS_SPECULAR_LIGHT | \
|
||||
EEVEE_RENDER_PASS_ENVIRONMENT)
|
||||
#define MAX_MATERIAL_RENDER_PASSES 6
|
||||
#define MAX_MATERIAL_RENDER_PASSES_UBO 6
|
||||
/* World shader variations */
|
||||
enum {
|
||||
VAR_WORLD_BACKGROUND = 0,
|
||||
VAR_WORLD_PROBE = 1,
|
||||
VAR_WORLD_VOLUME = 2,
|
||||
};
|
||||
|
||||
/* Material shader variations */
|
||||
enum {
|
||||
VAR_MAT_MESH = (1 << 0),
|
||||
VAR_MAT_PROBE = (1 << 1),
|
||||
VAR_MAT_VOLUME = (1 << 1),
|
||||
VAR_MAT_HAIR = (1 << 2),
|
||||
VAR_MAT_BLEND = (1 << 3),
|
||||
VAR_MAT_VOLUME = (1 << 4),
|
||||
VAR_MAT_PROBE = (1 << 3),
|
||||
VAR_MAT_BLEND = (1 << 4),
|
||||
VAR_MAT_LOOKDEV = (1 << 5),
|
||||
VAR_MAT_HOLDOUT = (1 << 6),
|
||||
/* Max number of variation */
|
||||
/* IMPORTANT : Leave it last and set
|
||||
* it's value accordingly. */
|
||||
VAR_MAT_MAX = (1 << 7),
|
||||
/* 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),
|
||||
VAR_MAT_HASH = (1 << 10),
|
||||
VAR_MAT_MULT = (1 << 11),
|
||||
VAR_MAT_SHADOW = (1 << 12),
|
||||
VAR_MAT_REFRACT = (1 << 13),
|
||||
VAR_MAT_HASH = (1 << 7),
|
||||
VAR_MAT_DEPTH = (1 << 8),
|
||||
VAR_MAT_REFRACT = (1 << 9),
|
||||
VAR_WORLD_BACKGROUND = (1 << 10),
|
||||
VAR_WORLD_PROBE = (1 << 11),
|
||||
VAR_WORLD_VOLUME = (1 << 12),
|
||||
VAR_DEFAULT = (1 << 13),
|
||||
};
|
||||
|
||||
/* ************ PROBE UBO ************* */
|
||||
@@ -272,23 +260,26 @@ typedef struct EEVEE_PassList {
|
||||
struct DRWPass *maxz_copydepth_ps;
|
||||
struct DRWPass *maxz_copydepth_layer_ps;
|
||||
|
||||
struct DRWPass *depth_pass;
|
||||
struct DRWPass *depth_pass_cull;
|
||||
struct DRWPass *depth_pass_clip;
|
||||
struct DRWPass *depth_pass_clip_cull;
|
||||
struct DRWPass *refract_depth_pass;
|
||||
struct DRWPass *refract_depth_pass_cull;
|
||||
struct DRWPass *refract_depth_pass_clip;
|
||||
struct DRWPass *refract_depth_pass_clip_cull;
|
||||
struct DRWPass *default_pass[VAR_MAT_MAX];
|
||||
struct DRWPass *sss_pass;
|
||||
struct DRWPass *sss_pass_cull;
|
||||
struct DRWPass *material_pass;
|
||||
struct DRWPass *material_pass_cull;
|
||||
struct DRWPass *material_accum_pass[MAX_MATERIAL_RENDER_PASSES];
|
||||
struct DRWPass *refract_pass;
|
||||
/* Renderpass Accumulation. */
|
||||
struct DRWPass *material_accum_ps;
|
||||
struct DRWPass *background_accum_ps;
|
||||
|
||||
struct DRWPass *depth_ps;
|
||||
struct DRWPass *depth_cull_ps;
|
||||
struct DRWPass *depth_clip_ps;
|
||||
struct DRWPass *depth_clip_cull_ps;
|
||||
struct DRWPass *depth_refract_ps;
|
||||
struct DRWPass *depth_refract_cull_ps;
|
||||
struct DRWPass *depth_refract_clip_ps;
|
||||
struct DRWPass *depth_refract_clip_cull_ps;
|
||||
struct DRWPass *material_ps;
|
||||
struct DRWPass *material_cull_ps;
|
||||
struct DRWPass *material_refract_ps;
|
||||
struct DRWPass *material_refract_cull_ps;
|
||||
struct DRWPass *material_sss_ps;
|
||||
struct DRWPass *material_sss_cull_ps;
|
||||
struct DRWPass *transparent_pass;
|
||||
struct DRWPass *background_pass;
|
||||
struct DRWPass *background_ps;
|
||||
struct DRWPass *update_noise_pass;
|
||||
struct DRWPass *lookdev_glossy_pass;
|
||||
struct DRWPass *lookdev_diffuse_pass;
|
||||
@@ -348,7 +339,12 @@ typedef struct EEVEE_TextureList {
|
||||
struct GPUTexture *mist_accum;
|
||||
struct GPUTexture *ao_accum;
|
||||
struct GPUTexture *sss_accum;
|
||||
struct GPUTexture *material_accum[MAX_MATERIAL_RENDER_PASSES];
|
||||
struct GPUTexture *env_accum;
|
||||
struct GPUTexture *diff_color_accum;
|
||||
struct GPUTexture *diff_light_accum;
|
||||
struct GPUTexture *spec_color_accum;
|
||||
struct GPUTexture *spec_light_accum;
|
||||
struct GPUTexture *emit_accum;
|
||||
struct GPUTexture *bloom_accum;
|
||||
struct GPUTexture *ssr_accum;
|
||||
struct GPUTexture *shadow_accum;
|
||||
@@ -574,6 +570,7 @@ typedef struct EEVEE_EffectsInfo {
|
||||
bool swap_double_buffer;
|
||||
/* SSSS */
|
||||
int sss_sample_count;
|
||||
int sss_surface_count;
|
||||
struct GPUTexture *sss_irradiance; /* Textures from pool */
|
||||
struct GPUTexture *sss_radius;
|
||||
struct GPUTexture *sss_albedo;
|
||||
@@ -754,14 +751,22 @@ typedef struct EEVEE_ViewLayerData {
|
||||
struct GPUUniformBuffer *planar_ubo;
|
||||
|
||||
/* Material Render passes */
|
||||
struct EEVEE_RenderPassData renderpass_data[MAX_MATERIAL_RENDER_PASSES_UBO];
|
||||
struct GPUUniformBuffer *renderpass_ubo[MAX_MATERIAL_RENDER_PASSES_UBO];
|
||||
struct {
|
||||
struct GPUUniformBuffer *combined;
|
||||
struct GPUUniformBuffer *diff_color;
|
||||
struct GPUUniformBuffer *diff_light;
|
||||
struct GPUUniformBuffer *spec_color;
|
||||
struct GPUUniformBuffer *spec_light;
|
||||
struct GPUUniformBuffer *emit;
|
||||
} renderpass_ubo;
|
||||
|
||||
/* Common Uniform Buffer */
|
||||
struct EEVEE_CommonUniformBuffer common_data;
|
||||
struct GPUUniformBuffer *common_ubo;
|
||||
|
||||
struct LightCache *fallback_lightcache;
|
||||
|
||||
struct BLI_memblock *material_cache;
|
||||
} EEVEE_ViewLayerData;
|
||||
|
||||
/* ************ OBJECT DATA ************ */
|
||||
@@ -809,14 +814,6 @@ typedef struct EEVEE_Data {
|
||||
typedef struct EEVEE_PrivateData {
|
||||
struct DRWShadingGroup *shadow_shgrp;
|
||||
struct DRWShadingGroup *shadow_accum_shgrp;
|
||||
struct DRWShadingGroup *depth_shgrp;
|
||||
struct DRWShadingGroup *depth_shgrp_cull;
|
||||
struct DRWShadingGroup *depth_shgrp_clip;
|
||||
struct DRWShadingGroup *depth_shgrp_clip_cull;
|
||||
struct DRWShadingGroup *refract_depth_shgrp;
|
||||
struct DRWShadingGroup *refract_depth_shgrp_cull;
|
||||
struct DRWShadingGroup *refract_depth_shgrp_clip;
|
||||
struct DRWShadingGroup *refract_depth_shgrp_clip_cull;
|
||||
struct DRWCallBuffer *planar_display_shgrp;
|
||||
struct GHash *material_hash;
|
||||
float background_alpha; /* TODO find a better place for this. */
|
||||
@@ -862,9 +859,8 @@ typedef struct EEVEE_PrivateData {
|
||||
GPUTexture *renderpass_input;
|
||||
GPUTexture *renderpass_col_input;
|
||||
GPUTexture *renderpass_light_input;
|
||||
/* The number of active material based render passes */
|
||||
uint render_passes_material_count;
|
||||
|
||||
/* Renderpass ubo reference used by material pass. */
|
||||
struct GPUUniformBuffer *renderpass_ubo;
|
||||
/** For rendering shadows. */
|
||||
struct DRWView *cube_views[6];
|
||||
/** For rendering probes. */
|
||||
@@ -892,6 +888,7 @@ EEVEE_WorldEngineData *EEVEE_world_data_ensure(World *wo);
|
||||
/* eevee_materials.c */
|
||||
struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */
|
||||
void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
|
||||
EEVEE_Data *vedata,
|
||||
EEVEE_StorageList *stl,
|
||||
EEVEE_FramebufferList *fbl);
|
||||
void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
|
||||
@@ -908,31 +905,20 @@ void EEVEE_object_hair_cache_populate(EEVEE_Data *vedata,
|
||||
Object *ob,
|
||||
bool *cast_shadow);
|
||||
void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
|
||||
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);
|
||||
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);
|
||||
struct GPUUniformBuffer *EEVEE_material_default_render_pass_ubo_get(EEVEE_ViewLayerData *sldata);
|
||||
void EEVEE_materials_free(void);
|
||||
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]);
|
||||
void EEVEE_material_renderpasses_init(EEVEE_Data *vedata);
|
||||
void EEVEE_material_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, uint tot_samples);
|
||||
void EEVEE_material_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
|
||||
int EEVEE_material_output_pass_index_get(EEVEE_ViewLayerData *UNUSED(sldata),
|
||||
EEVEE_Data *vedata,
|
||||
eViewLayerEEVEEPassType renderpass_type);
|
||||
int EEVEE_material_output_color_pass_index_get(EEVEE_ViewLayerData *sldata,
|
||||
EEVEE_Data *vedata,
|
||||
eViewLayerEEVEEPassType renderpass_type);
|
||||
void EEVEE_material_bind_resources(DRWShadingGroup *shgrp,
|
||||
struct GPUMaterial *gpumat,
|
||||
EEVEE_ViewLayerData *sldata,
|
||||
EEVEE_Data *vedata,
|
||||
int *ssr_id,
|
||||
float *refract_depth,
|
||||
bool use_ssrefraction,
|
||||
bool use_alpha_blend);
|
||||
/* eevee_lights.c */
|
||||
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);
|
||||
@@ -943,16 +929,6 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
|
||||
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);
|
||||
@@ -986,6 +962,7 @@ 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);
|
||||
void EEVEE_shaders_material_shaders_init(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_default_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_filter_diffuse_sh_get(void);
|
||||
@@ -993,12 +970,22 @@ struct GPUShader *EEVEE_shaders_probe_filter_visibility_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_grid_fill_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_default_studiolight_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_default_background_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_background_studiolight_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_update_noise_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_velocity_resolve_sh_get(void);
|
||||
struct GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects);
|
||||
struct bNodeTree *EEVEE_shader_default_surface_nodetree(Material *ma);
|
||||
struct bNodeTree *EEVEE_shader_default_world_nodetree(World *wo);
|
||||
Material *EEVEE_material_default_diffuse_get(void);
|
||||
Material *EEVEE_material_default_glossy_get(void);
|
||||
Material *EEVEE_material_default_error_get(void);
|
||||
struct GPUMaterial *EEVEE_material_default_get(struct Scene *scene, Material *ma, int options);
|
||||
struct GPUMaterial *EEVEE_material_get(
|
||||
EEVEE_Data *vedata, struct Scene *scene, Material *ma, World *wo, int options);
|
||||
void EEVEE_shaders_free(void);
|
||||
|
||||
/* eevee_lightprobes.c */
|
||||
@@ -1105,13 +1092,9 @@ void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *sldata,
|
||||
uint tot_samples);
|
||||
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);
|
||||
Material *ma,
|
||||
DRWShadingGroup *shgrp,
|
||||
struct GPUMaterial *gpumat);
|
||||
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);
|
||||
|
@@ -151,7 +151,7 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
|
||||
* `EEVEE_effects_init` needs to go second for TAA. */
|
||||
EEVEE_renderpasses_init(vedata);
|
||||
EEVEE_effects_init(sldata, vedata, ob_camera_eval, false);
|
||||
EEVEE_materials_init(sldata, stl, fbl);
|
||||
EEVEE_materials_init(sldata, vedata, stl, fbl);
|
||||
EEVEE_shadows_init(sldata);
|
||||
EEVEE_lightprobes_init(sldata, vedata);
|
||||
|
||||
@@ -463,7 +463,7 @@ static void eevee_render_draw_background(EEVEE_Data *vedata)
|
||||
GPU_ATTACHMENT_NONE});
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
|
||||
DRW_draw_pass(psl->background_pass);
|
||||
DRW_draw_pass(psl->background_ps);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->main_fb,
|
||||
{GPU_ATTACHMENT_LEAVE,
|
||||
@@ -556,7 +556,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
|
||||
EEVEE_update_noise(psl, fbl, r);
|
||||
EEVEE_temporal_sampling_matrices_calc(stl->effects, r);
|
||||
EEVEE_volumes_set_jitter(sldata, stl->effects->taa_current_sample - 1);
|
||||
EEVEE_materials_init(sldata, stl, fbl);
|
||||
EEVEE_materials_init(sldata, vedata, stl, fbl);
|
||||
|
||||
/* Refresh Probes
|
||||
* Shadows needs to be updated for correct probes */
|
||||
@@ -578,8 +578,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
GPU_framebuffer_clear_color_depth_stencil(fbl->main_fb, clear_col, clear_depth, clear_stencil);
|
||||
/* Depth prepass */
|
||||
DRW_draw_pass(psl->depth_pass);
|
||||
DRW_draw_pass(psl->depth_pass_cull);
|
||||
DRW_draw_pass(psl->depth_ps);
|
||||
/* Create minmax texture */
|
||||
EEVEE_create_minmax_buffer(vedata, dtxl->depth, -1);
|
||||
EEVEE_occlusion_compute(sldata, vedata, dtxl->depth, -1);
|
||||
@@ -587,16 +586,15 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
|
||||
/* Shading pass */
|
||||
eevee_render_draw_background(vedata);
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
EEVEE_materials_draw_opaque(sldata, psl);
|
||||
DRW_draw_pass(psl->material_ps);
|
||||
EEVEE_subsurface_data_render(sldata, vedata);
|
||||
/* Effects pre-transparency */
|
||||
EEVEE_subsurface_compute(sldata, vedata);
|
||||
EEVEE_reflection_compute(sldata, vedata);
|
||||
EEVEE_refraction_compute(sldata, vedata);
|
||||
/* Opaque refraction */
|
||||
DRW_draw_pass(psl->refract_depth_pass);
|
||||
DRW_draw_pass(psl->refract_depth_pass_cull);
|
||||
DRW_draw_pass(psl->refract_pass);
|
||||
DRW_draw_pass(psl->depth_refract_ps);
|
||||
DRW_draw_pass(psl->material_refract_ps);
|
||||
/* Result NORMAL */
|
||||
eevee_render_result_normal(rl, viewname, rect, vedata, sldata);
|
||||
/* Volumetrics Resolve Opaque */
|
||||
|
@@ -201,8 +201,7 @@ void EEVEE_renderpasses_output_init(EEVEE_ViewLayerData *sldata,
|
||||
grp, "inputSecondLightBuffer", &g_data->renderpass_light_input);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_int(grp, "currentSample", &g_data->renderpass_current_sample, 1);
|
||||
DRW_shgroup_uniform_int(grp, "renderpassType", &g_data->renderpass_type, 1);
|
||||
DRW_shgroup_uniform_int(grp, "postProcessType", &g_data->renderpass_postprocess, 1);
|
||||
@@ -225,7 +224,7 @@ void EEVEE_renderpasses_output_init(EEVEE_ViewLayerData *sldata,
|
||||
* Only invoke this function for passes that need post-processing.
|
||||
*
|
||||
* After invoking this function the active framebuffer is set to `vedata->fbl->renderpass_fb`. */
|
||||
void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *sldata,
|
||||
void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *UNUSED(sldata),
|
||||
EEVEE_Data *vedata,
|
||||
eViewLayerEEVEEPassType renderpass_type)
|
||||
{
|
||||
@@ -276,22 +275,30 @@ void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *sldata,
|
||||
g_data->renderpass_input = txl->shadow_accum;
|
||||
break;
|
||||
}
|
||||
case EEVEE_RENDER_PASS_DIFFUSE_COLOR:
|
||||
case EEVEE_RENDER_PASS_SPECULAR_COLOR:
|
||||
case EEVEE_RENDER_PASS_ENVIRONMENT:
|
||||
case EEVEE_RENDER_PASS_DIFFUSE_COLOR: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_COLOR;
|
||||
g_data->renderpass_input = txl->diff_color_accum;
|
||||
break;
|
||||
}
|
||||
case EEVEE_RENDER_PASS_SPECULAR_COLOR: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_COLOR;
|
||||
g_data->renderpass_input = txl->spec_color_accum;
|
||||
break;
|
||||
}
|
||||
case EEVEE_RENDER_PASS_ENVIRONMENT: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_COLOR;
|
||||
g_data->renderpass_input = txl->env_accum;
|
||||
break;
|
||||
}
|
||||
case EEVEE_RENDER_PASS_EMIT: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_COLOR;
|
||||
int renderpass_index = EEVEE_material_output_pass_index_get(sldata, vedata, renderpass_type);
|
||||
g_data->renderpass_input = txl->material_accum[renderpass_index];
|
||||
g_data->renderpass_input = txl->emit_accum;
|
||||
break;
|
||||
}
|
||||
case EEVEE_RENDER_PASS_SPECULAR_LIGHT: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_LIGHT;
|
||||
int renderpass_index = EEVEE_material_output_pass_index_get(sldata, vedata, renderpass_type);
|
||||
int renderpass_index_color = EEVEE_material_output_color_pass_index_get(
|
||||
sldata, vedata, renderpass_type);
|
||||
g_data->renderpass_input = txl->material_accum[renderpass_index];
|
||||
g_data->renderpass_col_input = txl->material_accum[renderpass_index_color];
|
||||
g_data->renderpass_input = txl->spec_light_accum;
|
||||
g_data->renderpass_col_input = txl->spec_color_accum;
|
||||
if ((stl->effects->enabled_effects & EFFECT_SSR) != 0) {
|
||||
g_data->renderpass_postprocess = PASS_POST_TWO_LIGHT_BUFFERS;
|
||||
g_data->renderpass_light_input = txl->ssr_accum;
|
||||
@@ -303,11 +310,8 @@ void EEVEE_renderpasses_postprocess(EEVEE_ViewLayerData *sldata,
|
||||
}
|
||||
case EEVEE_RENDER_PASS_DIFFUSE_LIGHT: {
|
||||
g_data->renderpass_postprocess = PASS_POST_ACCUMULATED_LIGHT;
|
||||
int renderpass_index = EEVEE_material_output_pass_index_get(sldata, vedata, renderpass_type);
|
||||
int renderpass_index_color = EEVEE_material_output_color_pass_index_get(
|
||||
sldata, vedata, renderpass_type);
|
||||
g_data->renderpass_input = txl->material_accum[renderpass_index];
|
||||
g_data->renderpass_col_input = txl->material_accum[renderpass_index_color];
|
||||
g_data->renderpass_input = txl->diff_light_accum;
|
||||
g_data->renderpass_col_input = txl->diff_color_accum;
|
||||
if ((stl->effects->enabled_effects & EFFECT_SSS) != 0) {
|
||||
g_data->renderpass_postprocess = PASS_POST_TWO_LIGHT_BUFFERS;
|
||||
g_data->renderpass_light_input = txl->sss_accum;
|
||||
@@ -343,10 +347,6 @@ void EEVEE_renderpasses_output_accumulate(EEVEE_ViewLayerData *sldata,
|
||||
if ((render_pass & EEVEE_RENDER_PASS_MIST) != 0) {
|
||||
EEVEE_mist_output_accumulate(sldata, vedata);
|
||||
}
|
||||
if ((render_pass & EEVEE_RENDER_PASS_DIFFUSE_LIGHT) != 0 &&
|
||||
(effects->enabled_effects & EFFECT_SSS) != 0) {
|
||||
EEVEE_subsurface_output_accumulate(sldata, vedata);
|
||||
}
|
||||
if ((render_pass & EEVEE_RENDER_PASS_AO) != 0) {
|
||||
EEVEE_occlusion_output_accumulate(sldata, vedata);
|
||||
}
|
||||
|
@@ -237,8 +237,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
if (!effects->reflection_trace_full) {
|
||||
DRW_shgroup_uniform_ivec2(grp, "halfresOffset", effects->ssr_halfres_ofs, 1);
|
||||
}
|
||||
@@ -259,8 +258,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_int(grp, "neighborOffset", &effects->ssr_neighbor_ofs, 1);
|
||||
if ((effects->enabled_effects & EFFECT_GTAO) != 0) {
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
|
@@ -22,12 +22,20 @@
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_string_utils.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "GPU_material.h"
|
||||
#include "GPU_shader.h"
|
||||
|
||||
#include "NOD_shader.h"
|
||||
|
||||
#include "eevee_engine.h"
|
||||
#include "eevee_private.h"
|
||||
|
||||
static const char *filter_defines = "#define HAMMERSLEY_SIZE " STRINGIFY(HAMMERSLEY_SIZE) "\n"
|
||||
@@ -61,6 +69,38 @@ static struct {
|
||||
struct GPUShader *taa_resolve_sh;
|
||||
struct GPUShader *taa_resolve_reproject_sh;
|
||||
|
||||
/* General purpose Shaders. */
|
||||
struct GPUShader *default_background;
|
||||
struct GPUShader *update_noise_sh;
|
||||
|
||||
/* Shader strings */
|
||||
char *frag_shader_lib;
|
||||
char *vert_shader_str;
|
||||
char *vert_shadow_shader_str;
|
||||
char *vert_background_shader_str;
|
||||
char *vert_volume_shader_str;
|
||||
char *geom_volume_shader_str;
|
||||
char *volume_shader_lib;
|
||||
|
||||
/* LookDev Materials */
|
||||
Material *glossy_mat;
|
||||
Material *diffuse_mat;
|
||||
|
||||
Material *error_mat;
|
||||
|
||||
/* Default Material */
|
||||
struct {
|
||||
bNodeTree *ntree;
|
||||
bNodeSocketValueRGBA *color_socket;
|
||||
bNodeSocketValueFloat *metallic_socket;
|
||||
bNodeSocketValueFloat *roughness_socket;
|
||||
bNodeSocketValueFloat *specular_socket;
|
||||
} surface;
|
||||
|
||||
struct {
|
||||
bNodeTree *ntree;
|
||||
bNodeSocketValueRGBA *color_socket;
|
||||
} world;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
extern char datatoc_bsdf_common_lib_glsl[];
|
||||
@@ -68,27 +108,42 @@ extern char datatoc_bsdf_sampling_lib_glsl[];
|
||||
extern char datatoc_common_uniforms_lib_glsl[];
|
||||
extern char datatoc_common_view_lib_glsl[];
|
||||
|
||||
extern char datatoc_ambient_occlusion_lib_glsl[];
|
||||
extern char datatoc_background_vert_glsl[];
|
||||
extern char datatoc_common_hair_lib_glsl[];
|
||||
extern char datatoc_cubemap_lib_glsl[];
|
||||
extern char datatoc_default_world_frag_glsl[];
|
||||
extern char datatoc_lightprobe_geom_glsl[];
|
||||
extern char datatoc_lightprobe_vert_glsl[];
|
||||
extern char datatoc_irradiance_lib_glsl[];
|
||||
extern char datatoc_lightprobe_cube_display_frag_glsl[];
|
||||
extern char datatoc_lightprobe_cube_display_vert_glsl[];
|
||||
extern char datatoc_lightprobe_filter_diffuse_frag_glsl[];
|
||||
extern char datatoc_lightprobe_filter_glossy_frag_glsl[];
|
||||
extern char datatoc_lightprobe_filter_visibility_frag_glsl[];
|
||||
extern char datatoc_lightprobe_geom_glsl[];
|
||||
extern char datatoc_lightprobe_grid_display_frag_glsl[];
|
||||
extern char datatoc_lightprobe_grid_display_vert_glsl[];
|
||||
extern char datatoc_lightprobe_grid_fill_frag_glsl[];
|
||||
extern char datatoc_lightprobe_lib_glsl[];
|
||||
extern char datatoc_lightprobe_planar_display_frag_glsl[];
|
||||
extern char datatoc_lightprobe_planar_display_vert_glsl[];
|
||||
extern char datatoc_lightprobe_planar_downsample_frag_glsl[];
|
||||
extern char datatoc_lightprobe_planar_downsample_geom_glsl[];
|
||||
extern char datatoc_lightprobe_planar_downsample_vert_glsl[];
|
||||
extern char datatoc_irradiance_lib_glsl[];
|
||||
extern char datatoc_lightprobe_lib_glsl[];
|
||||
extern char datatoc_lightprobe_vert_glsl[];
|
||||
extern char datatoc_lights_lib_glsl[];
|
||||
extern char datatoc_lit_surface_frag_glsl[];
|
||||
extern char datatoc_lit_surface_vert_glsl[];
|
||||
extern char datatoc_ltc_lib_glsl[];
|
||||
extern char datatoc_octahedron_lib_glsl[];
|
||||
extern char datatoc_cubemap_lib_glsl[];
|
||||
extern char datatoc_prepass_frag_glsl[];
|
||||
extern char datatoc_raytrace_lib_glsl[];
|
||||
extern char datatoc_shadow_vert_glsl[];
|
||||
extern char datatoc_ssr_lib_glsl[];
|
||||
extern char datatoc_update_noise_frag_glsl[];
|
||||
extern char datatoc_volumetric_frag_glsl[];
|
||||
extern char datatoc_volumetric_geom_glsl[];
|
||||
extern char datatoc_volumetric_lib_glsl[];
|
||||
extern char datatoc_volumetric_vert_glsl[];
|
||||
|
||||
/* Velocity Resolve */
|
||||
extern char datatoc_effect_velocity_resolve_frag_glsl[];
|
||||
@@ -150,6 +205,64 @@ void EEVEE_shaders_lightprobe_shaders_init(void)
|
||||
NULL);
|
||||
}
|
||||
|
||||
void EEVEE_shaders_material_shaders_init(void)
|
||||
{
|
||||
e_data.frag_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
|
||||
datatoc_common_uniforms_lib_glsl,
|
||||
datatoc_bsdf_common_lib_glsl,
|
||||
datatoc_bsdf_sampling_lib_glsl,
|
||||
datatoc_ambient_occlusion_lib_glsl,
|
||||
datatoc_raytrace_lib_glsl,
|
||||
datatoc_ssr_lib_glsl,
|
||||
datatoc_octahedron_lib_glsl,
|
||||
datatoc_cubemap_lib_glsl,
|
||||
datatoc_irradiance_lib_glsl,
|
||||
datatoc_lightprobe_lib_glsl,
|
||||
datatoc_ltc_lib_glsl,
|
||||
datatoc_lights_lib_glsl,
|
||||
/* Add one for each Closure */
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_lit_surface_frag_glsl,
|
||||
datatoc_volumetric_lib_glsl);
|
||||
|
||||
e_data.volume_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
|
||||
datatoc_common_uniforms_lib_glsl,
|
||||
datatoc_bsdf_common_lib_glsl,
|
||||
datatoc_ambient_occlusion_lib_glsl,
|
||||
datatoc_octahedron_lib_glsl,
|
||||
datatoc_cubemap_lib_glsl,
|
||||
datatoc_irradiance_lib_glsl,
|
||||
datatoc_lightprobe_lib_glsl,
|
||||
datatoc_ltc_lib_glsl,
|
||||
datatoc_lights_lib_glsl,
|
||||
datatoc_volumetric_lib_glsl,
|
||||
datatoc_volumetric_frag_glsl);
|
||||
|
||||
e_data.vert_shader_str = BLI_string_joinN(
|
||||
datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_lit_surface_vert_glsl);
|
||||
|
||||
e_data.vert_shadow_shader_str = BLI_string_joinN(
|
||||
datatoc_common_view_lib_glsl, datatoc_common_hair_lib_glsl, datatoc_shadow_vert_glsl);
|
||||
|
||||
e_data.vert_background_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
|
||||
datatoc_background_vert_glsl);
|
||||
|
||||
e_data.vert_volume_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
|
||||
datatoc_volumetric_vert_glsl);
|
||||
|
||||
e_data.geom_volume_shader_str = BLI_string_joinN(datatoc_common_view_lib_glsl,
|
||||
datatoc_volumetric_geom_glsl);
|
||||
}
|
||||
|
||||
GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void)
|
||||
{
|
||||
return e_data.probe_filter_glossy_sh;
|
||||
@@ -292,6 +405,26 @@ GPUShader *EEVEE_shaders_velocity_resolve_sh_get(void)
|
||||
return e_data.velocity_resolve_sh;
|
||||
}
|
||||
|
||||
GPUShader *EEVEE_shaders_default_background_sh_get(void)
|
||||
{
|
||||
if (e_data.default_background == NULL) {
|
||||
e_data.default_background = DRW_shader_create_with_lib(datatoc_background_vert_glsl,
|
||||
NULL,
|
||||
datatoc_default_world_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
NULL);
|
||||
}
|
||||
return e_data.default_background;
|
||||
}
|
||||
|
||||
GPUShader *EEVEE_shaders_update_noise_sh_get(void)
|
||||
{
|
||||
if (e_data.update_noise_sh == NULL) {
|
||||
e_data.update_noise_sh = DRW_shader_create_fullscreen(datatoc_update_noise_frag_glsl, NULL);
|
||||
}
|
||||
return e_data.update_noise_sh;
|
||||
}
|
||||
|
||||
GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects)
|
||||
{
|
||||
GPUShader **sh;
|
||||
@@ -316,8 +449,330 @@ GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects)
|
||||
return *sh;
|
||||
}
|
||||
|
||||
Material *EEVEE_material_default_diffuse_get(void)
|
||||
{
|
||||
if (!e_data.diffuse_mat) {
|
||||
Material *ma = BKE_id_new_nomain(ID_MA, "EEVEEE default diffuse");
|
||||
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
ma->nodetree = ntree;
|
||||
ma->use_nodes = true;
|
||||
|
||||
bNode *bsdf = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_DIFFUSE);
|
||||
bNodeSocket *base_color = nodeFindSocket(bsdf, SOCK_IN, "Color");
|
||||
copy_v3_fl(((bNodeSocketValueRGBA *)base_color->default_value)->value, 0.8f);
|
||||
|
||||
bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
|
||||
|
||||
nodeAddLink(ntree,
|
||||
bsdf,
|
||||
nodeFindSocket(bsdf, SOCK_OUT, "BSDF"),
|
||||
output,
|
||||
nodeFindSocket(output, SOCK_IN, "Surface"));
|
||||
|
||||
nodeSetActive(ntree, output);
|
||||
e_data.diffuse_mat = ma;
|
||||
}
|
||||
return e_data.diffuse_mat;
|
||||
}
|
||||
|
||||
Material *EEVEE_material_default_glossy_get(void)
|
||||
{
|
||||
if (!e_data.glossy_mat) {
|
||||
Material *ma = BKE_id_new_nomain(ID_MA, "EEVEEE default metal");
|
||||
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
ma->nodetree = ntree;
|
||||
ma->use_nodes = true;
|
||||
|
||||
bNode *bsdf = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_GLOSSY);
|
||||
bNodeSocket *base_color = nodeFindSocket(bsdf, SOCK_IN, "Color");
|
||||
copy_v3_fl(((bNodeSocketValueRGBA *)base_color->default_value)->value, 1.0f);
|
||||
bNodeSocket *roughness = nodeFindSocket(bsdf, SOCK_IN, "Roughness");
|
||||
((bNodeSocketValueFloat *)roughness->default_value)->value = 0.0f;
|
||||
|
||||
bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
|
||||
|
||||
nodeAddLink(ntree,
|
||||
bsdf,
|
||||
nodeFindSocket(bsdf, SOCK_OUT, "BSDF"),
|
||||
output,
|
||||
nodeFindSocket(output, SOCK_IN, "Surface"));
|
||||
|
||||
nodeSetActive(ntree, output);
|
||||
e_data.glossy_mat = ma;
|
||||
}
|
||||
return e_data.glossy_mat;
|
||||
}
|
||||
|
||||
Material *EEVEE_material_default_error_get(void)
|
||||
{
|
||||
if (!e_data.error_mat) {
|
||||
Material *ma = BKE_id_new_nomain(ID_MA, "EEVEEE default metal");
|
||||
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
ma->nodetree = ntree;
|
||||
ma->use_nodes = true;
|
||||
|
||||
/* Use emission and output material to be compatible with both World and Material. */
|
||||
bNode *bsdf = nodeAddStaticNode(NULL, ntree, SH_NODE_EMISSION);
|
||||
bNodeSocket *color = nodeFindSocket(bsdf, SOCK_IN, "Color");
|
||||
copy_v3_fl3(((bNodeSocketValueRGBA *)color->default_value)->value, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
|
||||
|
||||
nodeAddLink(ntree,
|
||||
bsdf,
|
||||
nodeFindSocket(bsdf, SOCK_OUT, "Emission"),
|
||||
output,
|
||||
nodeFindSocket(output, SOCK_IN, "Surface"));
|
||||
|
||||
nodeSetActive(ntree, output);
|
||||
e_data.error_mat = ma;
|
||||
}
|
||||
return e_data.error_mat;
|
||||
}
|
||||
|
||||
/* Configure a default nodetree with the given material. */
|
||||
struct bNodeTree *EEVEE_shader_default_surface_nodetree(Material *ma)
|
||||
{
|
||||
/* WARNING: This function is not threadsafe. Which is not a problem for the moment. */
|
||||
if (!e_data.surface.ntree) {
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
bNode *bsdf = nodeAddStaticNode(NULL, ntree, SH_NODE_BSDF_PRINCIPLED);
|
||||
bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL);
|
||||
bNodeSocket *bsdf_out = nodeFindSocket(bsdf, SOCK_OUT, "BSDF");
|
||||
bNodeSocket *output_in = nodeFindSocket(output, SOCK_IN, "Surface");
|
||||
nodeAddLink(ntree, bsdf, bsdf_out, output, output_in);
|
||||
nodeSetActive(ntree, output);
|
||||
|
||||
e_data.surface.color_socket = nodeFindSocket(bsdf, SOCK_IN, "Base Color")->default_value;
|
||||
e_data.surface.metallic_socket = nodeFindSocket(bsdf, SOCK_IN, "Metallic")->default_value;
|
||||
e_data.surface.roughness_socket = nodeFindSocket(bsdf, SOCK_IN, "Roughness")->default_value;
|
||||
e_data.surface.specular_socket = nodeFindSocket(bsdf, SOCK_IN, "Specular")->default_value;
|
||||
e_data.surface.ntree = ntree;
|
||||
}
|
||||
/* Update */
|
||||
copy_v3_fl3(e_data.surface.color_socket->value, ma->r, ma->g, ma->b);
|
||||
e_data.surface.metallic_socket->value = ma->metallic;
|
||||
e_data.surface.roughness_socket->value = ma->roughness;
|
||||
e_data.surface.specular_socket->value = ma->spec;
|
||||
|
||||
return e_data.surface.ntree;
|
||||
}
|
||||
|
||||
/* Configure a default nodetree with the given world. */
|
||||
struct bNodeTree *EEVEE_shader_default_world_nodetree(World *wo)
|
||||
{
|
||||
/* WARNING: This function is not threadsafe. Which is not a problem for the moment. */
|
||||
if (!e_data.world.ntree) {
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
bNode *bg = nodeAddStaticNode(NULL, ntree, SH_NODE_BACKGROUND);
|
||||
bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_WORLD);
|
||||
bNodeSocket *bg_out = nodeFindSocket(bg, SOCK_OUT, "Background");
|
||||
bNodeSocket *output_in = nodeFindSocket(output, SOCK_IN, "Surface");
|
||||
nodeAddLink(ntree, bg, bg_out, output, output_in);
|
||||
nodeSetActive(ntree, output);
|
||||
|
||||
e_data.world.color_socket = nodeFindSocket(bg, SOCK_IN, "Color")->default_value;
|
||||
e_data.world.ntree = ntree;
|
||||
}
|
||||
|
||||
copy_v3_fl3(e_data.world.color_socket->value, wo->horr, wo->horg, wo->horb);
|
||||
|
||||
return e_data.world.ntree;
|
||||
}
|
||||
|
||||
static char *eevee_get_defines(int options)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
DynStr *ds = BLI_dynstr_new();
|
||||
BLI_dynstr_append(ds, SHADER_DEFINES);
|
||||
|
||||
if ((options & VAR_WORLD_BACKGROUND) != 0) {
|
||||
BLI_dynstr_append(ds, "#define WORLD_BACKGROUND\n");
|
||||
}
|
||||
if ((options & VAR_MAT_VOLUME) != 0) {
|
||||
BLI_dynstr_append(ds, "#define VOLUMETRICS\n");
|
||||
}
|
||||
if ((options & VAR_MAT_MESH) != 0) {
|
||||
BLI_dynstr_append(ds, "#define MESH_SHADER\n");
|
||||
}
|
||||
if ((options & VAR_MAT_DEPTH) != 0) {
|
||||
BLI_dynstr_append(ds, "#define DEPTH_SHADER\n");
|
||||
}
|
||||
if ((options & VAR_MAT_HAIR) != 0) {
|
||||
BLI_dynstr_append(ds, "#define HAIR_SHADER\n");
|
||||
}
|
||||
if ((options & (VAR_MAT_PROBE | VAR_WORLD_PROBE)) != 0) {
|
||||
BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n");
|
||||
}
|
||||
if ((options & VAR_MAT_HASH) != 0) {
|
||||
BLI_dynstr_append(ds, "#define USE_ALPHA_HASH\n");
|
||||
}
|
||||
if ((options & VAR_MAT_BLEND) != 0) {
|
||||
BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND\n");
|
||||
}
|
||||
if ((options & VAR_MAT_REFRACT) != 0) {
|
||||
BLI_dynstr_append(ds, "#define USE_REFRACTION\n");
|
||||
}
|
||||
if ((options & VAR_MAT_LOOKDEV) != 0) {
|
||||
BLI_dynstr_append(ds, "#define LOOKDEV\n");
|
||||
}
|
||||
if ((options & VAR_MAT_HOLDOUT) != 0) {
|
||||
BLI_dynstr_append(ds, "#define HOLDOUT\n");
|
||||
}
|
||||
|
||||
str = BLI_dynstr_get_cstring(ds);
|
||||
BLI_dynstr_free(ds);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static char *eevee_get_vert(int options)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
if ((options & VAR_MAT_VOLUME) != 0) {
|
||||
str = BLI_strdup(e_data.vert_volume_shader_str);
|
||||
}
|
||||
else if ((options & (VAR_WORLD_PROBE | VAR_WORLD_BACKGROUND)) != 0) {
|
||||
str = BLI_strdup(e_data.vert_background_shader_str);
|
||||
}
|
||||
else {
|
||||
str = BLI_strdup(e_data.vert_shader_str);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static char *eevee_get_geom(int options)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
if ((options & VAR_MAT_VOLUME) != 0) {
|
||||
str = BLI_strdup(e_data.geom_volume_shader_str);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static char *eevee_get_frag(int options)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
if ((options & VAR_MAT_VOLUME) != 0) {
|
||||
str = BLI_strdup(e_data.volume_shader_lib);
|
||||
}
|
||||
else if ((options & VAR_MAT_DEPTH) != 0) {
|
||||
str = BLI_string_joinN(e_data.frag_shader_lib, datatoc_prepass_frag_glsl);
|
||||
}
|
||||
else {
|
||||
str = BLI_strdup(e_data.frag_shader_lib);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static struct GPUMaterial *eevee_material_get_ex(
|
||||
struct Scene *scene, Material *ma, World *wo, int options, bool deferred)
|
||||
{
|
||||
BLI_assert(ma || wo);
|
||||
const bool is_volume = (options & VAR_MAT_VOLUME) != 0;
|
||||
const bool is_default = (options & VAR_DEFAULT) != 0;
|
||||
const void *engine = &DRW_engine_viewport_eevee_type;
|
||||
|
||||
GPUMaterial *mat = NULL;
|
||||
|
||||
if (ma) {
|
||||
mat = DRW_shader_find_from_material(ma, engine, options, deferred);
|
||||
}
|
||||
else {
|
||||
mat = DRW_shader_find_from_world(wo, engine, options, deferred);
|
||||
}
|
||||
|
||||
if (mat) {
|
||||
return mat;
|
||||
}
|
||||
|
||||
char *defines = eevee_get_defines(options);
|
||||
char *vert = eevee_get_vert(options);
|
||||
char *geom = eevee_get_geom(options);
|
||||
char *frag = eevee_get_frag(options);
|
||||
|
||||
if (ma) {
|
||||
bNodeTree *ntree = !is_default ? ma->nodetree : EEVEE_shader_default_surface_nodetree(ma);
|
||||
mat = DRW_shader_create_from_material(
|
||||
scene, ma, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred);
|
||||
}
|
||||
else {
|
||||
bNodeTree *ntree = !is_default ? wo->nodetree : EEVEE_shader_default_world_nodetree(wo);
|
||||
mat = DRW_shader_create_from_world(
|
||||
scene, wo, ntree, engine, options, is_volume, vert, geom, frag, defines, deferred);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(defines);
|
||||
MEM_SAFE_FREE(vert);
|
||||
MEM_SAFE_FREE(geom);
|
||||
MEM_SAFE_FREE(frag);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
/* Note: Compilation is not deferred. */
|
||||
struct GPUMaterial *EEVEE_material_default_get(struct Scene *scene, Material *ma, int options)
|
||||
{
|
||||
Material *def_ma = (ma && (options & VAR_MAT_VOLUME)) ? BKE_material_default_volume() :
|
||||
BKE_material_default_surface();
|
||||
BLI_assert(def_ma->use_nodes && def_ma->nodetree);
|
||||
|
||||
return eevee_material_get_ex(scene, def_ma, NULL, options, false);
|
||||
}
|
||||
|
||||
struct GPUMaterial *EEVEE_material_get(
|
||||
EEVEE_Data *vedata, struct Scene *scene, Material *ma, World *wo, int options)
|
||||
{
|
||||
if ((ma && (!ma->use_nodes || !ma->nodetree)) || (wo && (!wo->use_nodes || !wo->nodetree))) {
|
||||
options |= VAR_DEFAULT;
|
||||
}
|
||||
|
||||
/* Meh, implicit option. World probe cannot be deferred because they need
|
||||
* to be rendered immediatly. */
|
||||
const bool deferred = (options & VAR_WORLD_PROBE) == 0;
|
||||
|
||||
GPUMaterial *mat = eevee_material_get_ex(scene, ma, wo, options, deferred);
|
||||
|
||||
int status = GPU_material_status(mat);
|
||||
switch (status) {
|
||||
case GPU_MAT_SUCCESS:
|
||||
break;
|
||||
case GPU_MAT_QUEUED:
|
||||
vedata->stl->g_data->queued_shaders_count++;
|
||||
mat = EEVEE_material_default_get(scene, ma, options);
|
||||
break;
|
||||
case GPU_MAT_FAILED:
|
||||
default:
|
||||
ma = EEVEE_material_default_error_get();
|
||||
mat = eevee_material_get_ex(scene, ma, NULL, options, false);
|
||||
break;
|
||||
}
|
||||
/* Returned material should be ready to be drawn. */
|
||||
BLI_assert(GPU_material_status(mat) == GPU_MAT_SUCCESS);
|
||||
return mat;
|
||||
}
|
||||
|
||||
void EEVEE_shaders_free(void)
|
||||
{
|
||||
MEM_SAFE_FREE(e_data.frag_shader_lib);
|
||||
MEM_SAFE_FREE(e_data.vert_shader_str);
|
||||
MEM_SAFE_FREE(e_data.vert_shadow_shader_str);
|
||||
MEM_SAFE_FREE(e_data.vert_background_shader_str);
|
||||
MEM_SAFE_FREE(e_data.vert_volume_shader_str);
|
||||
MEM_SAFE_FREE(e_data.geom_volume_shader_str);
|
||||
MEM_SAFE_FREE(e_data.volume_shader_lib);
|
||||
DRW_SHADER_FREE_SAFE(e_data.default_background);
|
||||
DRW_SHADER_FREE_SAFE(e_data.update_noise_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.probe_default_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.probe_filter_glossy_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.probe_filter_diffuse_sh);
|
||||
@@ -332,4 +787,27 @@ void EEVEE_shaders_free(void)
|
||||
DRW_SHADER_FREE_SAFE(e_data.velocity_resolve_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.taa_resolve_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.taa_resolve_reproject_sh);
|
||||
|
||||
if (e_data.glossy_mat) {
|
||||
BKE_id_free(NULL, e_data.glossy_mat);
|
||||
e_data.glossy_mat = NULL;
|
||||
}
|
||||
if (e_data.diffuse_mat) {
|
||||
BKE_id_free(NULL, e_data.diffuse_mat);
|
||||
e_data.diffuse_mat = NULL;
|
||||
}
|
||||
if (e_data.error_mat) {
|
||||
BKE_id_free(NULL, e_data.error_mat);
|
||||
e_data.error_mat = NULL;
|
||||
}
|
||||
if (e_data.surface.ntree) {
|
||||
ntreeFreeEmbeddedTree(e_data.surface.ntree);
|
||||
MEM_freeN(e_data.surface.ntree);
|
||||
e_data.surface.ntree = NULL;
|
||||
}
|
||||
if (e_data.world.ntree) {
|
||||
ntreeFreeEmbeddedTree(e_data.world.ntree);
|
||||
MEM_freeN(e_data.world.ntree);
|
||||
e_data.world.ntree = NULL;
|
||||
}
|
||||
}
|
||||
|
@@ -159,47 +159,6 @@ void EEVEE_shadows_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a shadow caster to the shadowpasses */
|
||||
void EEVEE_shadows_caster_add(EEVEE_ViewLayerData *UNUSED(sldata),
|
||||
EEVEE_StorageList *stl,
|
||||
struct GPUBatch *geom,
|
||||
Object *ob)
|
||||
{
|
||||
DRW_shgroup_call(stl->g_data->shadow_shgrp, geom, 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)
|
||||
{
|
||||
/* TODO / PERF : reuse the same shading group for objects with the same material */
|
||||
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass);
|
||||
|
||||
if (grp == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Unfortunately needed for correctness but not 99% of the time not needed.
|
||||
* TODO detect when needed? */
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
|
||||
if (alpha_threshold != NULL) {
|
||||
DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1);
|
||||
}
|
||||
|
||||
DRW_shgroup_call(grp, geom, ob);
|
||||
}
|
||||
|
||||
/* Make that object update shadow casting lights inside its influence bounding box. */
|
||||
void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, Object *ob)
|
||||
{
|
||||
@@ -470,8 +429,7 @@ void EEVEE_shadow_output_init(EEVEE_ViewLayerData *sldata,
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "shadowCubeTexture", &sldata->shadow_cube_pool);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "shadowCascadeTexture", &sldata->shadow_cascade_pool);
|
||||
|
||||
|
@@ -29,7 +29,9 @@
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "GPU_extensions.h"
|
||||
#include "GPU_material.h"
|
||||
#include "GPU_texture.h"
|
||||
|
||||
#include "eevee_private.h"
|
||||
|
||||
static struct {
|
||||
@@ -83,6 +85,7 @@ void EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
|
||||
|
||||
effects->sss_sample_count = 1 + scene_eval->eevee.sss_samples * 2;
|
||||
effects->sss_surface_count = 0;
|
||||
common_data->sss_jitter_threshold = scene_eval->eevee.sss_jitter_threshold;
|
||||
}
|
||||
|
||||
@@ -221,70 +224,77 @@ void EEVEE_subsurface_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data
|
||||
|
||||
void EEVEE_subsurface_add_pass(EEVEE_ViewLayerData *sldata,
|
||||
EEVEE_Data *vedata,
|
||||
uint sss_id,
|
||||
struct GPUUniformBuffer *sss_profile)
|
||||
Material *ma,
|
||||
DRWShadingGroup *shgrp,
|
||||
struct GPUMaterial *gpumat)
|
||||
{
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
EEVEE_PassList *psl = vedata->psl;
|
||||
EEVEE_StorageList *stl = vedata->stl;
|
||||
EEVEE_EffectsInfo *effects = stl->effects;
|
||||
struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
|
||||
GPUTexture **depth_src = GPU_depth_blitting_workaround() ? &effects->sss_stencil : &dtxl->depth;
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssIrradiance", &effects->sss_irradiance);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
|
||||
grp = DRW_shgroup_create(e_data.sss_sh[1], psl->sss_resolve_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssIrradiance", &effects->sss_blur);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssAlbedo", &effects->sss_albedo);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
}
|
||||
|
||||
void EEVEE_subsurface_translucency_add_pass(EEVEE_ViewLayerData *sldata,
|
||||
EEVEE_Data *vedata,
|
||||
uint sss_id,
|
||||
struct GPUUniformBuffer *sss_profile,
|
||||
GPUTexture *sss_tex_profile)
|
||||
{
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
EEVEE_PassList *psl = vedata->psl;
|
||||
EEVEE_StorageList *stl = vedata->stl;
|
||||
EEVEE_EffectsInfo *effects = stl->effects;
|
||||
struct GPUBatch *quad = DRW_cache_fullscreen_quad_get();
|
||||
GPUTexture **depth_src = GPU_depth_blitting_workaround() ? &effects->sss_stencil : &dtxl->depth;
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[2], psl->sss_translucency_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture(grp, "sssTexProfile", sss_tex_profile);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssShadowCubes", &sldata->shadow_cube_pool);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssShadowCascades", &sldata->shadow_cascade_pool);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call(grp, quad, NULL);
|
||||
struct GPUTexture *sss_tex_profile = NULL;
|
||||
struct GPUUniformBuffer *sss_profile = GPU_material_sss_profile_get(
|
||||
gpumat, stl->effects->sss_sample_count, &sss_tex_profile);
|
||||
|
||||
if (!sss_profile) {
|
||||
BLI_assert(0 && "SSS pass requested but no SSS data was found");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Limit of 8 bit stencil buffer. ID 255 is refraction. */
|
||||
if (effects->sss_surface_count >= 254) {
|
||||
/* TODO : display message. */
|
||||
printf("Error: Too many different Subsurface shader in the scene.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int sss_id = ++(effects->sss_surface_count);
|
||||
/* Make main pass output stencil mask. */
|
||||
DRW_shgroup_stencil_mask(shgrp, sss_id);
|
||||
|
||||
{
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssIrradiance", &effects->sss_irradiance);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
|
||||
|
||||
grp = DRW_shgroup_create(e_data.sss_sh[1], psl->sss_resolve_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssIrradiance", &effects->sss_blur);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssAlbedo", &effects->sss_albedo);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
|
||||
}
|
||||
|
||||
if (ma->blend_flag & MA_BL_TRANSLUCENCY) {
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[2], psl->sss_translucency_ps);
|
||||
DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
|
||||
DRW_shgroup_uniform_texture(grp, "sssTexProfile", sss_tex_profile);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", depth_src);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssRadius", &effects->sss_radius);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssShadowCubes", &sldata->shadow_cube_pool);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "sssShadowCascades", &sldata->shadow_cascade_pool);
|
||||
DRW_shgroup_uniform_block(grp, "sssProfile", sss_profile);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
DRW_shgroup_stencil_mask(grp, sss_id);
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
|
||||
@@ -310,8 +320,7 @@ void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
|
||||
GPU_ATTACHMENT_TEXTURE(effects->sss_albedo)});
|
||||
|
||||
GPU_framebuffer_bind(fbl->main_fb);
|
||||
DRW_draw_pass(psl->sss_pass);
|
||||
DRW_draw_pass(psl->sss_pass_cull);
|
||||
DRW_draw_pass(psl->material_sss_ps);
|
||||
|
||||
/* Restore */
|
||||
GPU_framebuffer_ensure_config(&fbl->main_fb,
|
||||
|
@@ -292,8 +292,7 @@ void EEVEE_temporal_sampling_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data
|
||||
DRW_shgroup_uniform_texture_ref(grp, "colorHistoryBuffer", &txl->taa_history);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
if (effects->enabled_effects & EFFECT_TAA_REPROJECT) {
|
||||
// DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
@@ -355,7 +355,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
struct World *wo = scene->world;
|
||||
if (wo != NULL && wo->use_nodes && wo->nodetree &&
|
||||
!LOOK_DEV_STUDIO_LIGHT_ENABLED(draw_ctx->v3d)) {
|
||||
struct GPUMaterial *mat = EEVEE_material_world_volume_get(scene, wo);
|
||||
struct GPUMaterial *mat = EEVEE_material_get(vedata, scene, NULL, wo, VAR_MAT_VOLUME);
|
||||
|
||||
if (GPU_material_has_volume_output(mat)) {
|
||||
grp = DRW_shgroup_material_create(mat, psl->volumetric_world_ps);
|
||||
@@ -369,8 +369,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
/* Fix principle volumetric not working with world materials. */
|
||||
ListBase gpu_grids = GPU_material_volume_grids(mat);
|
||||
@@ -388,8 +387,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
/* If no world or volume material is present just clear the buffer with this drawcall */
|
||||
grp = DRW_shgroup_create(e_data.volumetric_clear_sh, psl->volumetric_world_ps);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
|
||||
}
|
||||
@@ -591,12 +589,10 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
|
||||
return;
|
||||
}
|
||||
|
||||
struct GPUMaterial *mat = EEVEE_material_mesh_volume_get(scene, ma);
|
||||
int mat_options = VAR_MAT_VOLUME | VAR_MAT_MESH;
|
||||
struct GPUMaterial *mat = EEVEE_material_get(vedata, scene, ma, NULL, mat_options);
|
||||
eGPUMaterialStatus status = GPU_material_status(mat);
|
||||
|
||||
if (status == GPU_MAT_QUEUED) {
|
||||
vedata->stl->g_data->queued_shaders_count++;
|
||||
}
|
||||
/* If shader failed to compile or is currently compiling. */
|
||||
if (status != GPU_MAT_SUCCESS) {
|
||||
return;
|
||||
@@ -610,8 +606,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
|
||||
@@ -662,8 +657,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
|
||||
|
||||
@@ -672,8 +666,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_texture_ref(grp, "volumeScattering", &txl->volume_scatter);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "volumeExtinction", &txl->volume_transmit);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_call_procedural_triangles(
|
||||
grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]);
|
||||
@@ -684,8 +677,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
||||
DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
|
||||
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
|
||||
}
|
||||
@@ -921,8 +913,7 @@ void EEVEE_volumes_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
|
||||
DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit);
|
||||
DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_block(
|
||||
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
|
||||
DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
|
||||
}
|
||||
else {
|
||||
/* There is no volumetrics in the scene. Use a shader to fill the accum textures with a default
|
||||
|
@@ -6,13 +6,9 @@
|
||||
|
||||
#if defined(MESH_SHADER)
|
||||
# if !defined(USE_ALPHA_HASH)
|
||||
# if !defined(USE_ALPHA_CLIP)
|
||||
# if !defined(SHADOW_SHADER)
|
||||
# if !defined(USE_MULTIPLY)
|
||||
# if !defined(USE_ALPHA_BLEND)
|
||||
# define ENABLE_DEFERED_AO
|
||||
# endif
|
||||
# endif
|
||||
# if !defined(DEPTH_SHADER)
|
||||
# if !defined(USE_ALPHA_BLEND)
|
||||
# define ENABLE_DEFERED_AO
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
@@ -928,7 +928,7 @@ Closure closure_emission(vec3 rgb)
|
||||
|
||||
/* Breaking this across multiple lines causes issues for some older GLSL compilers. */
|
||||
/* clang-format off */
|
||||
# if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && !defined(SHADOW_SHADER)
|
||||
# if defined(MESH_SHADER) && !defined(DEPTH_SHADER)
|
||||
/* clang-format on */
|
||||
# ifndef USE_ALPHA_BLEND
|
||||
layout(location = 0) out vec4 outRadiance;
|
||||
@@ -1001,6 +1001,10 @@ void main()
|
||||
outRadiance.rgb += cl.sss_irradiance.rgb * cl.sss_albedo.rgb * fac;
|
||||
# endif
|
||||
|
||||
# ifdef LOOKDEV
|
||||
gl_FragDepth = 0.0;
|
||||
# endif
|
||||
|
||||
# ifndef USE_ALPHA_BLEND
|
||||
float alpha_div = 1.0 / max(1e-8, alpha);
|
||||
outRadiance.rgb *= alpha_div;
|
||||
@@ -1011,6 +1015,6 @@ void main()
|
||||
# endif
|
||||
}
|
||||
|
||||
# endif /* MESH_SHADER && !SHADOW_SHADER */
|
||||
# endif /* MESH_SHADER */
|
||||
|
||||
#endif /* VOLUMETRICS */
|
||||
|
@@ -177,7 +177,7 @@ void CLOSURE_NAME(vec3 N
|
||||
out_refr = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#if defined(SHADOW_SHADER) || defined(WORLD_BACKGROUND)
|
||||
#if defined(DEPTH_SHADER) || defined(WORLD_BACKGROUND)
|
||||
/* This makes shader resources become unused and avoid issues with samplers. (see T59747) */
|
||||
return;
|
||||
#else
|
||||
|
@@ -4,11 +4,12 @@ in vec3 pos;
|
||||
in vec3 nor;
|
||||
#endif
|
||||
|
||||
#ifdef MESH_SHADER
|
||||
out vec3 worldPosition;
|
||||
out vec3 viewPosition;
|
||||
|
||||
out vec3 worldNormal;
|
||||
out vec3 viewNormal;
|
||||
#endif
|
||||
|
||||
#ifdef HAIR_SHADER
|
||||
out vec3 hairTangent;
|
||||
@@ -41,22 +42,28 @@ void main()
|
||||
hairThickness,
|
||||
hairThickTime);
|
||||
worldNormal = cross(hairTangent, binor);
|
||||
worldPosition = pos;
|
||||
vec3 world_pos = pos;
|
||||
#else
|
||||
worldPosition = point_object_to_world(pos);
|
||||
worldNormal = normalize(normal_object_to_world(nor));
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
#endif
|
||||
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
|
||||
/* Used for planar reflections */
|
||||
gl_ClipDistance[0] = dot(vec4(world_pos, 1.0), clipPlanes[0]);
|
||||
|
||||
#ifdef MESH_SHADER
|
||||
worldPosition = world_pos;
|
||||
viewPosition = point_world_to_view(worldPosition);
|
||||
|
||||
# ifndef HAIR_SHADER
|
||||
worldNormal = normalize(normal_object_to_world(nor));
|
||||
# endif
|
||||
|
||||
/* No need to normalize since this is just a rotation. */
|
||||
viewNormal = normal_world_to_view(worldNormal);
|
||||
|
||||
viewPosition = point_world_to_view(worldPosition);
|
||||
gl_Position = point_world_to_ndc(worldPosition);
|
||||
|
||||
/* Used for planar reflections */
|
||||
gl_ClipDistance[0] = dot(vec4(worldPosition, 1.0), clipPlanes[0]);
|
||||
|
||||
#ifdef USE_ATTR
|
||||
# ifdef USE_ATTR
|
||||
pass_attr(pos);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
@@ -45,26 +45,22 @@ float hashed_alpha_threshold(vec3 co)
|
||||
/* Find our final, uniformly distributed alpha threshold. */
|
||||
float threshold = (x < one_a) ? ((x < a) ? cases.x : cases.y) : cases.z;
|
||||
|
||||
/* Jitter the threshold for TAA accumulation. */
|
||||
threshold = fract(threshold + alphaHashOffset);
|
||||
|
||||
/* Avoids threshold == 0. */
|
||||
threshold = clamp(threshold, 1.0e-6, 1.0);
|
||||
|
||||
/* Jitter the threshold for TAA accumulation. */
|
||||
return fract(threshold + alphaHashOffset);
|
||||
return threshold;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_ALPHA_CLIP
|
||||
uniform float alphaThreshold;
|
||||
#endif
|
||||
#define NODETREE_EXEC
|
||||
|
||||
void main()
|
||||
{
|
||||
/* For now do nothing.
|
||||
* In the future, output object motion blur. */
|
||||
|
||||
#if defined(USE_ALPHA_HASH) || defined(USE_ALPHA_CLIP)
|
||||
# define NODETREE_EXEC
|
||||
#if defined(USE_ALPHA_HASH)
|
||||
|
||||
Closure cl = nodetree_exec();
|
||||
|
||||
@@ -75,11 +71,6 @@ void main()
|
||||
if (opacity < hashed_alpha_threshold(worldPosition)) {
|
||||
discard;
|
||||
}
|
||||
# elif defined(USE_ALPHA_CLIP)
|
||||
/* Alpha clip */
|
||||
if (opacity <= alphaThreshold) {
|
||||
discard;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
@@ -25,10 +25,12 @@
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
|
||||
@@ -166,6 +168,24 @@ static void external_cache_populate(void *vedata, Object *ob)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ob->type == OB_MESH && ob->modifiers.first != NULL) {
|
||||
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) {
|
||||
struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL);
|
||||
DRW_shgroup_call(stl->g_data->depth_shgrp, hairs, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
/* Depth Prepass */
|
||||
|
@@ -66,6 +66,7 @@ void OVERLAY_edit_curve_cache_init(OVERLAY_Data *vedata)
|
||||
|
||||
sh = OVERLAY_shader_edit_curve_point();
|
||||
pd->edit_curve_points_grp = grp = DRW_shgroup_create(sh, psl->edit_curve_handle_ps);
|
||||
DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles);
|
||||
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +95,7 @@ void OVERLAY_edit_curve_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
DRW_shgroup_call_no_cull(pd->edit_curve_handle_grp, geom, ob);
|
||||
}
|
||||
|
||||
geom = DRW_cache_curve_vert_overlay_get(ob, pd->edit_curve.show_handles);
|
||||
geom = DRW_cache_curve_vert_overlay_get(ob);
|
||||
if (geom) {
|
||||
DRW_shgroup_call_no_cull(pd->edit_curve_points_grp, geom, ob);
|
||||
}
|
||||
@@ -110,7 +111,7 @@ void OVERLAY_edit_surf_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
DRW_shgroup_call_no_cull(pd->edit_curve_handle_grp, geom, ob);
|
||||
}
|
||||
|
||||
geom = DRW_cache_curve_vert_overlay_get(ob, false);
|
||||
geom = DRW_cache_curve_vert_overlay_get(ob);
|
||||
if (geom) {
|
||||
DRW_shgroup_call_no_cull(pd->edit_curve_points_grp, geom, ob);
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0;
|
||||
|
||||
if (use_sculpt_pbvh) {
|
||||
DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false, false);
|
||||
DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false);
|
||||
}
|
||||
else {
|
||||
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
|
||||
|
@@ -60,8 +60,10 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
|
||||
const bool show_ortho_grid = (pd->v3d_gridflag & V3D_SHOW_ORTHO_GRID) != 0;
|
||||
|
||||
shd->grid_flag = 0;
|
||||
shd->zneg_flag = 0;
|
||||
shd->zpos_flag = 0;
|
||||
|
||||
if (pd->hide_overlays || !(show_axis_y || show_axis_z || show_floor || show_ortho_grid)) {
|
||||
if (pd->hide_overlays || !pd->v3d_gridflag) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
|
||||
if (use_pbvh || !ob->sculpt->deform_modifiers_active || ob->sculpt->shapekey_active) {
|
||||
if (!use_pbvh || pbvh_has_mask(pbvh) || pbvh_has_face_sets(pbvh)) {
|
||||
DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true, false);
|
||||
DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -230,7 +230,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
|
||||
DRW_shgroup_call_no_cull(shgrp, geom, ob);
|
||||
}
|
||||
else if (use_sculpt_pbvh) {
|
||||
DRW_shgroup_call_sculpt(shgrp, ob, true, false, false);
|
||||
DRW_shgroup_call_sculpt(shgrp, ob, true, false);
|
||||
}
|
||||
else {
|
||||
DRW_shgroup_call(shgrp, geom, ob);
|
||||
|
@@ -1,7 +1,8 @@
|
||||
|
||||
/* Keep the same value of `ACTIVE_NURB` in `draw_cache_imp_curve.c` */
|
||||
#define ACTIVE_NURB 1 << 2
|
||||
#define EVEN_U_BIT 1 << 3
|
||||
#define EVEN_U_BIT 1 << 4
|
||||
#define COLOR_SHIFT 5
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 10) out;
|
||||
@@ -37,7 +38,7 @@ void main()
|
||||
vec4 v2 = gl_in[1].gl_Position;
|
||||
|
||||
int is_active_nurb = (vertFlag[1] & ACTIVE_NURB);
|
||||
int color_id = (vertFlag[1] >> 4);
|
||||
int color_id = (vertFlag[1] >> COLOR_SHIFT);
|
||||
|
||||
/* Don't output any edges if we don't show handles */
|
||||
if (!showCurveHandles && (color_id < 5)) {
|
||||
|
@@ -1,4 +1,9 @@
|
||||
|
||||
/* Keep the same value of `BEZIER_HANDLE` in `draw_cache_imp_curve.c` */
|
||||
#define BEZIER_HANDLE 1 << 3
|
||||
|
||||
uniform bool showCurveHandles;
|
||||
|
||||
in vec3 pos;
|
||||
in int data;
|
||||
|
||||
@@ -26,4 +31,9 @@ void main()
|
||||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
world_clip_planes_calc_clip_distance(world_pos);
|
||||
#endif
|
||||
|
||||
if (!showCurveHandles && ((data & BEZIER_HANDLE) != 0)) {
|
||||
/* We set the vertex at the camera origin to generate 0 fragments. */
|
||||
gl_Position = vec4(0.0, 0.0, -3e36, 0.0);
|
||||
}
|
||||
}
|
||||
|
@@ -176,6 +176,14 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the TAA when we have already draw a sample, but the sample count differs from previous
|
||||
* time. This removes render artifacts when the viewport anti-aliasing in the user preferences is
|
||||
* set to a lower value. */
|
||||
if (wpd->taa_sample_len != wpd->taa_sample_len_previous) {
|
||||
wpd->taa_sample = 0;
|
||||
wpd->taa_sample_len_previous = wpd->taa_sample_len;
|
||||
}
|
||||
|
||||
if (wpd->view_updated) {
|
||||
wpd->taa_sample = 0;
|
||||
wpd->view_updated = false;
|
||||
|
@@ -55,6 +55,7 @@ void workbench_engine_init(void *ved)
|
||||
|
||||
if (!stl->wpd) {
|
||||
stl->wpd = MEM_callocN(sizeof(*stl->wpd), __func__);
|
||||
stl->wpd->taa_sample_len_previous = -1;
|
||||
stl->wpd->view_updated = true;
|
||||
}
|
||||
|
||||
@@ -112,13 +113,12 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
|
||||
Object *ob,
|
||||
eV3DShadingColorType color_type)
|
||||
{
|
||||
const bool use_vcol = ELEM(color_type, V3D_SHADING_VERTEX_COLOR);
|
||||
const bool use_single_drawcall = !ELEM(color_type, V3D_SHADING_MATERIAL_COLOR);
|
||||
BLI_assert(wpd->shading.color_type != V3D_SHADING_TEXTURE_COLOR);
|
||||
|
||||
if (use_single_drawcall) {
|
||||
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, NULL);
|
||||
DRW_shgroup_call_sculpt(grp, ob, false, false, use_vcol);
|
||||
DRW_shgroup_call_sculpt(grp, ob, false, false);
|
||||
}
|
||||
else {
|
||||
const int materials_len = DRW_cache_object_material_count_get(ob);
|
||||
@@ -126,7 +126,7 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
|
||||
for (int i = 0; i < materials_len; i++) {
|
||||
shgrps[i] = workbench_material_setup(wpd, ob, i + 1, color_type, NULL);
|
||||
}
|
||||
DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob, false);
|
||||
DRW_shgroup_call_sculpt_with_materials(shgrps, materials_len, ob);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -261,6 +261,8 @@ typedef struct WORKBENCH_PrivateData {
|
||||
/* Temporal Antialiasing */
|
||||
/** Total number of samples to after which TAA stops accumulating samples. */
|
||||
int taa_sample_len;
|
||||
/** Total number of samples of the previous TAA. When changed TAA will be reset. */
|
||||
int taa_sample_len_previous;
|
||||
/** Current TAA sample index in [0..taa_sample_len[ range. */
|
||||
int taa_sample;
|
||||
/** Inverse of taa_sample to divide the accumulation buffer. */
|
||||
|
@@ -224,6 +224,7 @@ struct GPUMaterial *DRW_shader_find_from_material(struct Material *ma,
|
||||
bool deferred);
|
||||
struct GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
struct World *wo,
|
||||
struct bNodeTree *ntree,
|
||||
const void *engine_type,
|
||||
const int options,
|
||||
const bool is_volume_shader,
|
||||
@@ -234,6 +235,7 @@ struct GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
bool deferred);
|
||||
struct GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
|
||||
struct Material *ma,
|
||||
struct bNodeTree *ntree,
|
||||
const void *engine_type,
|
||||
const int options,
|
||||
const bool is_volume_shader,
|
||||
@@ -365,6 +367,8 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
|
||||
DRWPass *pass,
|
||||
struct GPUVertBuf *tf_target);
|
||||
|
||||
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial *material);
|
||||
|
||||
/* return final visibility */
|
||||
typedef bool(DRWCallVisibilityFn)(bool vis_in, void *user_data);
|
||||
|
||||
@@ -410,11 +414,8 @@ void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup,
|
||||
struct GPUBatch *geom,
|
||||
struct GPUBatch *inst_attributes);
|
||||
|
||||
void DRW_shgroup_call_sculpt(DRWShadingGroup *sh, Object *ob, bool wire, bool mask, bool vcol);
|
||||
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **sh,
|
||||
int num_sh,
|
||||
Object *ob,
|
||||
bool vcol);
|
||||
void DRW_shgroup_call_sculpt(DRWShadingGroup *sh, Object *ob, bool wire, bool mask);
|
||||
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **sh, int num_sh, Object *ob);
|
||||
|
||||
DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shading_group,
|
||||
struct GPUVertFormat *format,
|
||||
@@ -466,15 +467,24 @@ void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup,
|
||||
void DRW_shgroup_uniform_texture_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const struct GPUTexture *tex);
|
||||
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUTexture **tex);
|
||||
void DRW_shgroup_uniform_texture_ref_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUTexture **tex);
|
||||
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const struct GPUUniformBuffer *ubo);
|
||||
void DRW_shgroup_uniform_block_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const struct GPUUniformBuffer *ubo);
|
||||
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUTexture **tex);
|
||||
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUUniformBuffer **ubo);
|
||||
void DRW_shgroup_uniform_block_ref_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUUniformBuffer **ubo);
|
||||
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float *value,
|
||||
@@ -529,6 +539,8 @@ bool DRW_shgroup_is_empty(DRWShadingGroup *shgroup);
|
||||
|
||||
/* Passes */
|
||||
DRWPass *DRW_pass_create(const char *name, DRWState state);
|
||||
DRWPass *DRW_pass_create_instance(const char *name, DRWPass *original, DRWState state);
|
||||
void DRW_pass_link(DRWPass *first, DRWPass *second);
|
||||
/* TODO Replace with passes inheritance. */
|
||||
void DRW_pass_state_set(DRWPass *pass, DRWState state);
|
||||
void DRW_pass_state_add(DRWPass *pass, DRWState state);
|
||||
@@ -542,6 +554,8 @@ void DRW_pass_sort_shgroup_reverse(DRWPass *pass);
|
||||
bool DRW_pass_is_empty(DRWPass *pass);
|
||||
|
||||
#define DRW_PASS_CREATE(pass, state) (pass = DRW_pass_create(#pass, state))
|
||||
#define DRW_PASS_INSTANCE_CREATE(pass, original, state) \
|
||||
(pass = DRW_pass_create_instance(#pass, (original), state))
|
||||
|
||||
/* Views */
|
||||
DRWView *DRW_view_create(const float viewmat[4][4],
|
||||
|
@@ -2898,12 +2898,12 @@ GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob)
|
||||
return DRW_curve_batch_cache_get_edit_edges(cu);
|
||||
}
|
||||
|
||||
GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob, bool handles)
|
||||
GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob)
|
||||
{
|
||||
BLI_assert(ELEM(ob->type, OB_CURVE, OB_SURF));
|
||||
|
||||
struct Curve *cu = ob->data;
|
||||
return DRW_curve_batch_cache_get_edit_verts(cu, handles);
|
||||
return DRW_curve_batch_cache_get_edit_verts(cu);
|
||||
}
|
||||
|
||||
GPUBatch *DRW_cache_curve_surface_get(Object *ob)
|
||||
|
@@ -150,7 +150,7 @@ struct GPUBatch *DRW_cache_curve_edge_detection_get(struct Object *ob, bool *r_i
|
||||
/* edit-mode */
|
||||
struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob);
|
||||
struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob);
|
||||
struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob, bool handles);
|
||||
struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob);
|
||||
|
||||
/* Font */
|
||||
struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob);
|
||||
|
@@ -93,7 +93,7 @@ struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu);
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(struct Curve *cu);
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold);
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_edit_edges(struct Curve *cu);
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu, bool handles);
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu);
|
||||
|
||||
struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu);
|
||||
struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu,
|
||||
|
@@ -49,7 +49,9 @@
|
||||
|
||||
#define SELECT 1
|
||||
#define ACTIVE_NURB 1 << 2
|
||||
#define EVEN_U_BIT 1 << 3 /* Alternate this bit for every U vert. */
|
||||
#define BEZIER_HANDLE 1 << 3
|
||||
#define EVEN_U_BIT 1 << 4 /* Alternate this bit for every U vert. */
|
||||
#define COLOR_SHIFT 5
|
||||
|
||||
/* Used as values of `color_id` in `edit_curve_overlay_handle_geom.glsl` */
|
||||
enum {
|
||||
@@ -376,7 +378,7 @@ typedef struct CurveBatchCache {
|
||||
GPUIndexBuf *curves_lines;
|
||||
GPUIndexBuf *edges_adj_lines;
|
||||
/* Edit mode */
|
||||
GPUIndexBuf *edit_verts_points; /* Only control points. Not handles. */
|
||||
GPUIndexBuf *edit_verts;
|
||||
GPUIndexBuf *edit_lines;
|
||||
} ibo;
|
||||
|
||||
@@ -387,7 +389,6 @@ typedef struct CurveBatchCache {
|
||||
/* control handles and vertices */
|
||||
GPUBatch *edit_edges;
|
||||
GPUBatch *edit_verts;
|
||||
GPUBatch *edit_handles_verts;
|
||||
GPUBatch *edit_normals;
|
||||
GPUBatch *edge_detection;
|
||||
} batch;
|
||||
@@ -497,7 +498,6 @@ void DRW_curve_batch_cache_dirty_tag(Curve *cu, int mode)
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_edges);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_verts);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_handles_verts);
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
@@ -686,14 +686,15 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, GPUVertBuf *vbo
|
||||
}
|
||||
|
||||
static char beztriple_vflag_get(
|
||||
CurveRenderData *rdata, char flag, char col_id, int v_idx, int nu_id)
|
||||
CurveRenderData *rdata, char flag, char col_id, int v_idx, int nu_id, bool handle_point)
|
||||
{
|
||||
char vflag = 0;
|
||||
SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED);
|
||||
SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
|
||||
SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
|
||||
SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE);
|
||||
/* handle color id */
|
||||
vflag |= col_id << 4; /* << 4 because of EVEN_U_BIT */
|
||||
vflag |= col_id << COLOR_SHIFT;
|
||||
return vflag;
|
||||
}
|
||||
|
||||
@@ -704,7 +705,7 @@ static char bpoint_vflag_get(CurveRenderData *rdata, char flag, int v_idx, int n
|
||||
SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE);
|
||||
SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB);
|
||||
SET_FLAG_FROM_TEST(vflag, ((u % 2) == 0), EVEN_U_BIT);
|
||||
vflag |= COLOR_NURB_ULINE_ID << 4; /* << 4 because of EVEN_U_BIT */
|
||||
vflag |= COLOR_NURB_ULINE_ID << COLOR_SHIFT;
|
||||
return vflag;
|
||||
}
|
||||
|
||||
@@ -760,7 +761,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
|
||||
}
|
||||
|
||||
if (elbp_verts) {
|
||||
GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 0);
|
||||
GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 1);
|
||||
GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 2);
|
||||
}
|
||||
if (elbp_lines) {
|
||||
GPU_indexbuf_add_line_verts(elbp_lines, vbo_len_used + 1, vbo_len_used + 0);
|
||||
@@ -768,9 +771,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata,
|
||||
}
|
||||
if (vbo_data) {
|
||||
const char vflag[3] = {
|
||||
beztriple_vflag_get(rdata, bezt->f1, bezt->h1, a, nu_id),
|
||||
beztriple_vflag_get(rdata, bezt->f2, bezt->h1, a, nu_id),
|
||||
beztriple_vflag_get(rdata, bezt->f3, bezt->h2, a, nu_id),
|
||||
beztriple_vflag_get(rdata, bezt->f1, bezt->h1, a, nu_id, true),
|
||||
beztriple_vflag_get(rdata, bezt->f2, bezt->h1, a, nu_id, false),
|
||||
beztriple_vflag_get(rdata, bezt->f3, bezt->h2, a, nu_id, true),
|
||||
};
|
||||
for (int j = 0; j < 3; j++) {
|
||||
GPU_vertbuf_attr_set(vbo_data, attr_id.data, vbo_len_used + j, &vflag[j]);
|
||||
@@ -859,15 +862,10 @@ GPUBatch *DRW_curve_batch_cache_get_edit_edges(Curve *cu)
|
||||
return DRW_batch_request(&cache->batch.edit_edges);
|
||||
}
|
||||
|
||||
GPUBatch *DRW_curve_batch_cache_get_edit_verts(Curve *cu, bool handles)
|
||||
GPUBatch *DRW_curve_batch_cache_get_edit_verts(Curve *cu)
|
||||
{
|
||||
CurveBatchCache *cache = curve_batch_cache_get(cu);
|
||||
if (handles) {
|
||||
return DRW_batch_request(&cache->batch.edit_handles_verts);
|
||||
}
|
||||
else {
|
||||
return DRW_batch_request(&cache->batch.edit_verts);
|
||||
}
|
||||
return DRW_batch_request(&cache->batch.edit_verts);
|
||||
}
|
||||
|
||||
GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu)
|
||||
@@ -965,14 +963,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
|
||||
DRW_vbo_request(cache->batch.edit_edges, &cache->edit.data);
|
||||
}
|
||||
if (DRW_batch_requested(cache->batch.edit_verts, GPU_PRIM_POINTS)) {
|
||||
DRW_ibo_request(cache->batch.edit_verts, &cache->ibo.edit_verts_points);
|
||||
DRW_ibo_request(cache->batch.edit_verts, &cache->ibo.edit_verts);
|
||||
DRW_vbo_request(cache->batch.edit_verts, &cache->edit.pos);
|
||||
DRW_vbo_request(cache->batch.edit_verts, &cache->edit.data);
|
||||
}
|
||||
if (DRW_batch_requested(cache->batch.edit_handles_verts, GPU_PRIM_POINTS)) {
|
||||
DRW_vbo_request(cache->batch.edit_handles_verts, &cache->edit.pos);
|
||||
DRW_vbo_request(cache->batch.edit_handles_verts, &cache->edit.data);
|
||||
}
|
||||
if (DRW_batch_requested(cache->batch.edit_normals, GPU_PRIM_LINES)) {
|
||||
DRW_vbo_request(cache->batch.edit_normals, &cache->edit.curves_nor);
|
||||
}
|
||||
@@ -1012,7 +1006,7 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
|
||||
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.data, CU_DATATYPE_OVERLAY);
|
||||
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_nor, CU_DATATYPE_NORMAL);
|
||||
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_weight, CU_DATATYPE_OVERLAY);
|
||||
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_verts_points, CU_DATATYPE_OVERLAY);
|
||||
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_verts, CU_DATATYPE_OVERLAY);
|
||||
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_lines, CU_DATATYPE_OVERLAY);
|
||||
|
||||
for (int i = 0; i < cache->mat_len; i++) {
|
||||
@@ -1065,13 +1059,9 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
|
||||
}
|
||||
|
||||
if (DRW_vbo_requested(cache->edit.pos) || DRW_vbo_requested(cache->edit.data) ||
|
||||
DRW_ibo_requested(cache->ibo.edit_verts_points) ||
|
||||
DRW_ibo_requested(cache->ibo.edit_lines)) {
|
||||
curve_create_edit_data_and_handles(rdata,
|
||||
cache->edit.pos,
|
||||
cache->edit.data,
|
||||
cache->ibo.edit_verts_points,
|
||||
cache->ibo.edit_lines);
|
||||
DRW_ibo_requested(cache->ibo.edit_verts) || DRW_ibo_requested(cache->ibo.edit_lines)) {
|
||||
curve_create_edit_data_and_handles(
|
||||
rdata, cache->edit.pos, cache->edit.data, cache->ibo.edit_verts, cache->ibo.edit_lines);
|
||||
}
|
||||
if (DRW_vbo_requested(cache->edit.curves_nor)) {
|
||||
curve_create_edit_curves_nor(rdata, cache->edit.curves_nor);
|
||||
|
@@ -172,23 +172,11 @@ bool DRW_object_axis_orthogonal_to_view(Object *ob, int axis);
|
||||
|
||||
/* This creates a shading group with display hairs.
|
||||
* The draw call is already added by this function, just add additional uniforms. */
|
||||
struct DRWShadingGroup *DRW_shgroup_hair_create(struct Object *object,
|
||||
struct ParticleSystem *psys,
|
||||
struct ModifierData *md,
|
||||
struct DRWPass *hair_pass,
|
||||
struct GPUShader *shader);
|
||||
|
||||
struct DRWShadingGroup *DRW_shgroup_hair_create_sub(struct Object *object,
|
||||
struct ParticleSystem *psys,
|
||||
struct ModifierData *md,
|
||||
struct DRWShadingGroup *shgrp);
|
||||
|
||||
struct DRWShadingGroup *DRW_shgroup_material_hair_create(struct Object *object,
|
||||
struct ParticleSystem *psys,
|
||||
struct ModifierData *md,
|
||||
struct DRWPass *hair_pass,
|
||||
struct GPUMaterial *material);
|
||||
|
||||
void DRW_hair_init(void);
|
||||
void DRW_hair_update(void);
|
||||
void DRW_hair_free(void);
|
||||
|
@@ -124,13 +124,10 @@ void DRW_hair_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
|
||||
ParticleSystem *psys,
|
||||
ModifierData *md,
|
||||
DRWPass *hair_pass,
|
||||
DRWShadingGroup *shgrp_parent,
|
||||
struct GPUMaterial *gpu_mat,
|
||||
GPUShader *gpu_shader)
|
||||
DRWShadingGroup *DRW_shgroup_hair_create_sub(Object *object,
|
||||
ParticleSystem *psys,
|
||||
ModifierData *md,
|
||||
DRWShadingGroup *shgrp_parent)
|
||||
{
|
||||
/* TODO(fclem): Pass the scene as parameter */
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
@@ -154,24 +151,7 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
|
||||
need_ft_update = hair_ensure_procedural_data(object, &hair_cache, subdiv, thickness_res);
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgrp;
|
||||
if (shgrp_parent) {
|
||||
shgrp = DRW_shgroup_create_sub(shgrp_parent);
|
||||
}
|
||||
else if (gpu_mat) {
|
||||
shgrp = DRW_shgroup_material_create(gpu_mat, hair_pass);
|
||||
}
|
||||
else if (gpu_shader) {
|
||||
shgrp = DRW_shgroup_create(gpu_shader, hair_pass);
|
||||
}
|
||||
else {
|
||||
shgrp = NULL;
|
||||
BLI_assert(0);
|
||||
}
|
||||
|
||||
if (shgrp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
DRWShadingGroup *shgrp = DRW_shgroup_create_sub(shgrp_parent);
|
||||
|
||||
/* TODO optimize this. Only bind the ones GPUMaterial needs. */
|
||||
for (int i = 0; i < hair_cache->num_uv_layers; i++) {
|
||||
@@ -287,29 +267,6 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
|
||||
return shgrp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_hair_create(
|
||||
Object *object, ParticleSystem *psys, ModifierData *md, DRWPass *hair_pass, GPUShader *shader)
|
||||
{
|
||||
return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, NULL, NULL, shader);
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_hair_create_sub(Object *object,
|
||||
ParticleSystem *psys,
|
||||
ModifierData *md,
|
||||
DRWShadingGroup *shgrp)
|
||||
{
|
||||
return drw_shgroup_create_hair_procedural_ex(object, psys, md, NULL, shgrp, NULL, NULL);
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_material_hair_create(Object *object,
|
||||
ParticleSystem *psys,
|
||||
ModifierData *md,
|
||||
DRWPass *hair_pass,
|
||||
struct GPUMaterial *material)
|
||||
{
|
||||
return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, NULL, material, NULL);
|
||||
}
|
||||
|
||||
void DRW_hair_update(void)
|
||||
{
|
||||
#ifndef USE_TRANSFORM_FEEDBACK
|
||||
|
@@ -278,8 +278,11 @@ typedef enum {
|
||||
DRW_UNIFORM_TEXTURE,
|
||||
DRW_UNIFORM_TEXTURE_PERSIST,
|
||||
DRW_UNIFORM_TEXTURE_REF,
|
||||
DRW_UNIFORM_TEXTURE_REF_PERSIST,
|
||||
DRW_UNIFORM_BLOCK,
|
||||
DRW_UNIFORM_BLOCK_PERSIST,
|
||||
DRW_UNIFORM_BLOCK_REF,
|
||||
DRW_UNIFORM_BLOCK_REF_PERSIST,
|
||||
DRW_UNIFORM_TFEEDBACK_TARGET,
|
||||
/** Per drawcall uniforms/UBO */
|
||||
DRW_UNIFORM_BLOCK_OBMATS,
|
||||
@@ -342,6 +345,13 @@ struct DRWPass {
|
||||
DRWShadingGroup *last;
|
||||
} shgroups;
|
||||
|
||||
/* Draw the shgroups of this pass instead.
|
||||
* This avoid duplicating drawcalls/shgroups
|
||||
* for similar passes. */
|
||||
DRWPass *original;
|
||||
/* Link list of additional passes to render. */
|
||||
DRWPass *next;
|
||||
|
||||
DRWResourceHandle handle;
|
||||
DRWState state;
|
||||
char name[MAX_PASS_NAME];
|
||||
|
@@ -228,7 +228,11 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup,
|
||||
int arraysize)
|
||||
{
|
||||
int location;
|
||||
if (ELEM(type, DRW_UNIFORM_BLOCK, DRW_UNIFORM_BLOCK_PERSIST)) {
|
||||
if (ELEM(type,
|
||||
DRW_UNIFORM_BLOCK,
|
||||
DRW_UNIFORM_BLOCK_PERSIST,
|
||||
DRW_UNIFORM_BLOCK_REF,
|
||||
DRW_UNIFORM_BLOCK_REF_PERSIST)) {
|
||||
location = GPU_shader_get_uniform_block(shgroup->shader, name);
|
||||
}
|
||||
else {
|
||||
@@ -284,6 +288,22 @@ void DRW_shgroup_uniform_texture_persistent(DRWShadingGroup *shgroup,
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE_PERSIST, tex, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
|
||||
{
|
||||
BLI_assert(tex != NULL);
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE_REF, tex, 0, 1);
|
||||
}
|
||||
|
||||
/* Same as DRW_shgroup_uniform_texture_ref but is guaranteed to be bound if shader does not change
|
||||
* between shgrp. */
|
||||
void DRW_shgroup_uniform_texture_ref_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUTexture **tex)
|
||||
{
|
||||
BLI_assert(tex != NULL);
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE_REF_PERSIST, tex, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const GPUUniformBuffer *ubo)
|
||||
@@ -302,9 +322,22 @@ void DRW_shgroup_uniform_block_persistent(DRWShadingGroup *shgroup,
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BLOCK_PERSIST, ubo, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
|
||||
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUUniformBuffer **ubo)
|
||||
{
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE_REF, tex, 0, 1);
|
||||
BLI_assert(ubo != NULL);
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BLOCK_REF, ubo, 0, 1);
|
||||
}
|
||||
|
||||
/* Same as DRW_shgroup_uniform_block_ref but is guaranteed to be bound if shader does not change
|
||||
* between shgrp. */
|
||||
void DRW_shgroup_uniform_block_ref_persistent(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
GPUUniformBuffer **ubo)
|
||||
{
|
||||
BLI_assert(ubo != NULL);
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BLOCK_REF_PERSIST, ubo, 0, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup,
|
||||
@@ -954,7 +987,7 @@ static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4])
|
||||
}
|
||||
}
|
||||
|
||||
static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
|
||||
static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
|
||||
{
|
||||
/* PBVH should always exist for non-empty meshes, created by depsgrah eval. */
|
||||
PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL;
|
||||
@@ -1015,7 +1048,6 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
|
||||
BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg);
|
||||
|
||||
BKE_pbvh_draw_cb(pbvh,
|
||||
use_vcol,
|
||||
update_only_visible,
|
||||
&update_frustum,
|
||||
&draw_frustum,
|
||||
@@ -1033,8 +1065,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_shgroup_call_sculpt(
|
||||
DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_vcol)
|
||||
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
|
||||
{
|
||||
DRWSculptCallbackData scd = {
|
||||
.ob = ob,
|
||||
@@ -1044,13 +1075,12 @@ void DRW_shgroup_call_sculpt(
|
||||
.use_mats = false,
|
||||
.use_mask = use_mask,
|
||||
};
|
||||
drw_sculpt_generate_calls(&scd, use_vcol);
|
||||
drw_sculpt_generate_calls(&scd);
|
||||
}
|
||||
|
||||
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
|
||||
int num_shgroups,
|
||||
Object *ob,
|
||||
bool use_vcol)
|
||||
Object *ob)
|
||||
{
|
||||
DRWSculptCallbackData scd = {
|
||||
.ob = ob,
|
||||
@@ -1060,7 +1090,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
|
||||
.use_mats = true,
|
||||
.use_mask = false,
|
||||
};
|
||||
drw_sculpt_generate_calls(&scd, use_vcol);
|
||||
drw_sculpt_generate_calls(&scd);
|
||||
}
|
||||
|
||||
static GPUVertFormat inst_select_format = {0};
|
||||
@@ -1296,15 +1326,14 @@ static void drw_shgroup_material_texture(DRWShadingGroup *grp,
|
||||
int textarget)
|
||||
{
|
||||
GPUTexture *gputex = GPU_texture_from_blender(tex->ima, tex->iuser, NULL, textarget);
|
||||
DRW_shgroup_uniform_texture(grp, name, gputex);
|
||||
DRW_shgroup_uniform_texture_persistent(grp, name, gputex);
|
||||
|
||||
GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images);
|
||||
*gputex_ref = gputex;
|
||||
GPU_texture_ref(gputex);
|
||||
}
|
||||
|
||||
static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
|
||||
struct GPUMaterial *material)
|
||||
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial *material)
|
||||
{
|
||||
ListBase textures = GPU_material_textures(material);
|
||||
|
||||
@@ -1322,7 +1351,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
|
||||
}
|
||||
else if (tex->colorband) {
|
||||
/* Color Ramp */
|
||||
DRW_shgroup_uniform_texture(grp, tex->sampler_name, *tex->colorband);
|
||||
DRW_shgroup_uniform_texture_persistent(grp, tex->sampler_name, *tex->colorband);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1330,8 +1359,6 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
|
||||
if (ubo != NULL) {
|
||||
DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
|
||||
}
|
||||
|
||||
return grp;
|
||||
}
|
||||
|
||||
GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[],
|
||||
@@ -1356,7 +1383,7 @@ DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPa
|
||||
|
||||
if (shgroup) {
|
||||
drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass));
|
||||
drw_shgroup_material_inputs(shgroup, material);
|
||||
DRW_shgroup_add_material_resources(shgroup, material);
|
||||
}
|
||||
return shgroup;
|
||||
}
|
||||
@@ -1907,9 +1934,28 @@ DRWPass *DRW_pass_create(const char *name, DRWState state)
|
||||
pass->handle = DST.pass_handle;
|
||||
DRW_handle_increment(&DST.pass_handle);
|
||||
|
||||
pass->original = NULL;
|
||||
pass->next = NULL;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
DRWPass *DRW_pass_create_instance(const char *name, DRWPass *original, DRWState state)
|
||||
{
|
||||
DRWPass *pass = DRW_pass_create(name, state);
|
||||
pass->original = original;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
/* Link two passes so that they are both rendered if the first one is being drawn. */
|
||||
void DRW_pass_link(DRWPass *first, DRWPass *second)
|
||||
{
|
||||
BLI_assert(first != second);
|
||||
BLI_assert(first->next == NULL);
|
||||
first->next = second;
|
||||
}
|
||||
|
||||
bool DRW_pass_is_empty(DRWPass *pass)
|
||||
{
|
||||
LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) {
|
||||
|
@@ -971,6 +971,12 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
|
||||
bind_texture(tex, BIND_TEMP);
|
||||
GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
|
||||
break;
|
||||
case DRW_UNIFORM_TEXTURE_REF_PERSIST:
|
||||
tex = *((GPUTexture **)uni->pvalue);
|
||||
BLI_assert(tex);
|
||||
bind_texture(tex, BIND_PERSIST);
|
||||
GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
|
||||
break;
|
||||
case DRW_UNIFORM_BLOCK:
|
||||
ubo = (GPUUniformBuffer *)uni->pvalue;
|
||||
bind_ubo(ubo, BIND_TEMP);
|
||||
@@ -981,6 +987,16 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
|
||||
bind_ubo(ubo, BIND_PERSIST);
|
||||
GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
|
||||
break;
|
||||
case DRW_UNIFORM_BLOCK_REF:
|
||||
ubo = *((GPUUniformBuffer **)uni->pvalue);
|
||||
bind_ubo(ubo, BIND_TEMP);
|
||||
GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
|
||||
break;
|
||||
case DRW_UNIFORM_BLOCK_REF_PERSIST:
|
||||
ubo = *((GPUUniformBuffer **)uni->pvalue);
|
||||
bind_ubo(ubo, BIND_PERSIST);
|
||||
GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
|
||||
break;
|
||||
case DRW_UNIFORM_BLOCK_OBMATS:
|
||||
state->obmats_loc = uni->location;
|
||||
ubo = DST.vmempool->matrices_ubo[0];
|
||||
@@ -1426,6 +1442,11 @@ static void drw_draw_pass_ex(DRWPass *pass,
|
||||
DRWShadingGroup *start_group,
|
||||
DRWShadingGroup *end_group)
|
||||
{
|
||||
if (pass->original) {
|
||||
start_group = pass->original->shgroups.first;
|
||||
end_group = pass->original->shgroups.last;
|
||||
}
|
||||
|
||||
if (start_group == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -1511,7 +1532,9 @@ static void drw_draw_pass_ex(DRWPass *pass,
|
||||
|
||||
void DRW_draw_pass(DRWPass *pass)
|
||||
{
|
||||
drw_draw_pass_ex(pass, pass->shgroups.first, pass->shgroups.last);
|
||||
for (; pass; pass = pass->next) {
|
||||
drw_draw_pass_ex(pass, pass->shgroups.first, pass->shgroups.last);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw only a subset of shgroups. Used in special situations as grease pencil strokes */
|
||||
|
@@ -395,6 +395,7 @@ GPUMaterial *DRW_shader_find_from_material(Material *ma,
|
||||
|
||||
GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
World *wo,
|
||||
struct bNodeTree *ntree,
|
||||
const void *engine_type,
|
||||
const int options,
|
||||
const bool is_volume_shader,
|
||||
@@ -405,7 +406,7 @@ GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
bool deferred)
|
||||
{
|
||||
GPUMaterial *mat = NULL;
|
||||
if (DRW_state_is_image_render()) {
|
||||
if (DRW_state_is_image_render() || !deferred) {
|
||||
mat = GPU_material_from_nodetree_find(&wo->gpumaterial, engine_type, options);
|
||||
}
|
||||
|
||||
@@ -413,7 +414,7 @@ GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id);
|
||||
mat = GPU_material_from_nodetree(scene,
|
||||
NULL,
|
||||
wo->nodetree,
|
||||
ntree,
|
||||
&wo->gpumaterial,
|
||||
engine_type,
|
||||
options,
|
||||
@@ -434,6 +435,7 @@ GPUMaterial *DRW_shader_create_from_world(struct Scene *scene,
|
||||
|
||||
GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
|
||||
Material *ma,
|
||||
struct bNodeTree *ntree,
|
||||
const void *engine_type,
|
||||
const int options,
|
||||
const bool is_volume_shader,
|
||||
@@ -444,7 +446,7 @@ GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
|
||||
bool deferred)
|
||||
{
|
||||
GPUMaterial *mat = NULL;
|
||||
if (DRW_state_is_image_render()) {
|
||||
if (DRW_state_is_image_render() || !deferred) {
|
||||
mat = GPU_material_from_nodetree_find(&ma->gpumaterial, engine_type, options);
|
||||
}
|
||||
|
||||
@@ -452,7 +454,7 @@ GPUMaterial *DRW_shader_create_from_material(struct Scene *scene,
|
||||
scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id);
|
||||
mat = GPU_material_from_nodetree(scene,
|
||||
ma,
|
||||
ma->nodetree,
|
||||
ntree,
|
||||
&ma->gpumaterial,
|
||||
engine_type,
|
||||
options,
|
||||
|
@@ -336,7 +336,7 @@ set(ICON_NAMES
|
||||
force_boid
|
||||
force_turbulence
|
||||
force_drag
|
||||
force_smokeflow
|
||||
force_fluidflow
|
||||
image_plane
|
||||
image_background
|
||||
image_reference
|
||||
|
@@ -381,7 +381,7 @@ static void dial_ghostarc_draw_with_helplines(const float angle_ofs,
|
||||
{
|
||||
/* Coordinate at which the arc drawing will be started. */
|
||||
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
|
||||
const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.4f};
|
||||
const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.2f};
|
||||
dial_ghostarc_draw(angle_ofs, angle_delta, arc_inner_factor, color_arc_inner);
|
||||
|
||||
float line_width = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) ? 3.0f : 1.0f;
|
||||
|
@@ -428,7 +428,7 @@ DEF_ICON(FORCE_CURVE)
|
||||
DEF_ICON(FORCE_BOID)
|
||||
DEF_ICON(FORCE_TURBULENCE)
|
||||
DEF_ICON(FORCE_DRAG)
|
||||
DEF_ICON(FORCE_SMOKEFLOW)
|
||||
DEF_ICON(FORCE_FLUIDFLOW)
|
||||
DEF_ICON_BLANK(673)
|
||||
DEF_ICON_BLANK(674)
|
||||
DEF_ICON(RIGID_BODY)
|
||||
|
@@ -146,7 +146,7 @@ static const EnumPropertyItem field_type_items[] = {
|
||||
{PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
|
||||
{PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
|
||||
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
|
||||
{PFIELD_SMOKEFLOW, "SMOKE", ICON_FORCE_SMOKEFLOW, "Smoke Flow", ""},
|
||||
{PFIELD_FLUIDFLOW, "FLUID", ICON_FORCE_FLUIDFLOW, "Fluid Flow", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
@@ -269,7 +269,7 @@ static void draw_azone_arrow(float x1, float y1, float x2, float y2, AZEdge edge
|
||||
GPU_blend(false);
|
||||
}
|
||||
|
||||
static void region_draw_azone_tab_arrow(AZone *az)
|
||||
static void region_draw_azone_tab_arrow(ScrArea *area, ARegion *region, AZone *az)
|
||||
{
|
||||
GPU_blend(true);
|
||||
|
||||
@@ -289,7 +289,9 @@ static void region_draw_azone_tab_arrow(AZone *az)
|
||||
break;
|
||||
}
|
||||
|
||||
float color[4] = {0.05f, 0.05f, 0.05f, 0.4f};
|
||||
/* Workaround for different color spaces between normal areas and the ones using GPUViewports. */
|
||||
float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f;
|
||||
float color[4] = {0.05f, 0.05f, 0.05f, alpha};
|
||||
UI_draw_roundbox_aa(
|
||||
true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color);
|
||||
|
||||
@@ -330,7 +332,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region)
|
||||
if (az->region) {
|
||||
/* only display tab or icons when the region is hidden */
|
||||
if (az->region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
|
||||
region_draw_azone_tab_arrow(az);
|
||||
region_draw_azone_tab_arrow(area, region, az);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4022,7 +4022,7 @@ static void project_paint_bleed_add_face_user(const ProjPaintState *ps,
|
||||
* Ideally this would be checked later, not to add to the cost of computing non-degenerate
|
||||
* triangles, but that would allow other triangles to still find adjacent seams on degenerate
|
||||
* triangles, potentially causing incorrect results. */
|
||||
if (area_tri_v2(UNPACK3(lt_tri_uv)) > FLT_EPSILON) {
|
||||
if (area_tri_v2(UNPACK3(lt_tri_uv)) > 0.0f) {
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
void *tri_index_p = POINTER_FROM_INT(tri_index);
|
||||
|
||||
|
@@ -220,31 +220,46 @@ static void draw_frame_curves(SpaceClip *sc, uint pos)
|
||||
MovieClip *clip = ED_space_clip_get_clip(sc);
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
|
||||
int i, lines = 0, prevfra = 0;
|
||||
|
||||
int previous_frame;
|
||||
float previous_error;
|
||||
bool have_previous_point = false;
|
||||
|
||||
/* Indicates whether immBegin() was called. */
|
||||
bool is_lines_segment_open = false;
|
||||
|
||||
immUniformColor3f(0.0f, 0.0f, 1.0f);
|
||||
|
||||
for (i = 0; i < reconstruction->camnr; i++) {
|
||||
for (int i = 0; i < reconstruction->camnr; i++) {
|
||||
MovieReconstructedCamera *camera = &reconstruction->cameras[i];
|
||||
int framenr;
|
||||
|
||||
if (lines && camera->framenr != prevfra + 1) {
|
||||
immEnd();
|
||||
lines = 0;
|
||||
const int current_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr);
|
||||
const float current_error = camera->error;
|
||||
|
||||
if (have_previous_point && current_frame != previous_frame + 1) {
|
||||
if (is_lines_segment_open) {
|
||||
immEnd();
|
||||
is_lines_segment_open = false;
|
||||
}
|
||||
have_previous_point = false;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr);
|
||||
lines = 1;
|
||||
if (have_previous_point) {
|
||||
if (!is_lines_segment_open) {
|
||||
immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr);
|
||||
is_lines_segment_open = true;
|
||||
|
||||
immVertex2f(pos, previous_frame, previous_error);
|
||||
}
|
||||
immVertex2f(pos, current_frame, current_error);
|
||||
}
|
||||
|
||||
framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr);
|
||||
immVertex2f(pos, framenr, camera->error);
|
||||
|
||||
prevfra = camera->framenr;
|
||||
previous_frame = current_frame;
|
||||
previous_error = current_error;
|
||||
have_previous_point = true;
|
||||
}
|
||||
|
||||
if (lines) {
|
||||
if (is_lines_segment_open) {
|
||||
immEnd();
|
||||
}
|
||||
}
|
||||
|
@@ -347,7 +347,7 @@ static void gizmo_get_axis_color(const int axis_idx,
|
||||
if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) {
|
||||
/* Never fade rotation rings. */
|
||||
/* trackball rotation axis is a special case, we only draw a slight overlay */
|
||||
alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f;
|
||||
alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.05f : 1.0f;
|
||||
}
|
||||
else {
|
||||
bool is_plane = false;
|
||||
|
@@ -190,6 +190,7 @@ void GPU_materials_free(struct Main *bmain);
|
||||
|
||||
struct Scene *GPU_material_scene(GPUMaterial *material);
|
||||
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
|
||||
struct GPUShader *GPU_material_get_shader(GPUMaterial *material);
|
||||
struct Material *GPU_material_get_material(GPUMaterial *material);
|
||||
eGPUMaterialStatus GPU_material_status(GPUMaterial *mat);
|
||||
|
||||
|
@@ -209,6 +209,11 @@ GPUPass *GPU_material_get_pass(GPUMaterial *material)
|
||||
return material->pass;
|
||||
}
|
||||
|
||||
GPUShader *GPU_material_get_shader(GPUMaterial *material)
|
||||
{
|
||||
return material->pass ? GPU_pass_shader_get(material->pass) : NULL;
|
||||
}
|
||||
|
||||
/* Return can be NULL if it's a world material. */
|
||||
Material *GPU_material_get_material(GPUMaterial *material)
|
||||
{
|
||||
@@ -662,6 +667,9 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
|
||||
/* Caller must re-use materials. */
|
||||
BLI_assert(GPU_material_from_nodetree_find(gpumaterials, engine_type, options) == NULL);
|
||||
|
||||
/* HACK: Eevee assume this to create Ghash keys. */
|
||||
BLI_assert(sizeof(GPUPass) > 16);
|
||||
|
||||
/* allocate material */
|
||||
GPUMaterial *mat = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
|
||||
mat->ma = ma;
|
||||
|
@@ -314,17 +314,10 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
if (mode == GPU_SELECT_PICK_ALL) {
|
||||
/* Note that other depth settings (such as #GL_LEQUAL) work too,
|
||||
* since the depth is always cleared.
|
||||
* Noting this for cases when depth picking is used where
|
||||
* drawing calls change depth settings. */
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
}
|
||||
else {
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
/* Always use #GL_LEQUAL even though GPU_SELECT_PICK_ALL always clears the buffer. This is
|
||||
* because individual objects themselves might have sections that overlap and we need these
|
||||
* to have the correct distance information. */
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
float viewport[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport);
|
||||
|
@@ -1576,6 +1576,7 @@ void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat gpu_data_format, const vo
|
||||
glClearTexImage(tex->bindcode, 0, data_format, data_type, color);
|
||||
}
|
||||
else {
|
||||
/* TODO(fclem) speedup using the copy framebuffer. */
|
||||
size_t buffer_len = gpu_texture_memory_footprint_compute(tex);
|
||||
unsigned char *pixels = MEM_mallocN(buffer_len, __func__);
|
||||
if (color) {
|
||||
|
@@ -35,4 +35,6 @@ void main()
|
||||
if (butCo > 0.0) {
|
||||
fragColor.a = 1.0;
|
||||
}
|
||||
|
||||
fragColor = blender_srgb_to_framebuffer_space(fragColor);
|
||||
}
|
||||
|
@@ -1,8 +1,16 @@
|
||||
void node_output_material(Closure surface, Closure volume, vec3 displacement, out Closure result)
|
||||
void node_output_material(
|
||||
Closure surface, Closure volume, vec3 displacement, float alpha_threshold, out Closure result)
|
||||
{
|
||||
#ifdef VOLUMETRICS
|
||||
result = volume;
|
||||
#else
|
||||
result = surface;
|
||||
# if defined(USE_ALPHA_HASH)
|
||||
/* Alpha clip emulation. */
|
||||
if (alpha_threshold >= 0.0) {
|
||||
float alpha = saturate(1.0 - avg(result.transmittance));
|
||||
result.transmittance = vec3(step(alpha, alpha_threshold));
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
@@ -59,8 +59,8 @@ typedef enum ePFieldType {
|
||||
PFIELD_TURBULENCE = 11,
|
||||
/** Linear & quadratic drag. */
|
||||
PFIELD_DRAG = 12,
|
||||
/** Force based on smoke simulation air flow. */
|
||||
PFIELD_SMOKEFLOW = 13,
|
||||
/** Force based on fluid simulation velocities. */
|
||||
PFIELD_FLUIDFLOW = 13,
|
||||
|
||||
/* Keep last. */
|
||||
NUM_PFIELD_TYPES,
|
||||
|
@@ -1332,7 +1332,7 @@ static void rna_def_effector_weight(BlenderRNA *brna)
|
||||
RNA_def_property_float_sdna(prop, NULL, "weight[13]");
|
||||
RNA_def_property_range(prop, -200.0f, 200.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
|
||||
RNA_def_property_ui_text(prop, "Smoke Flow", "Smoke Flow effector weight");
|
||||
RNA_def_property_ui_text(prop, "Fluid Flow", "Fluid Flow effector weight");
|
||||
RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
|
||||
}
|
||||
|
||||
@@ -1396,11 +1396,11 @@ static void rna_def_field(BlenderRNA *brna)
|
||||
"Turbulence",
|
||||
"Create turbulence with a noise field"},
|
||||
{PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", "Create a force that dampens motion"},
|
||||
{PFIELD_SMOKEFLOW,
|
||||
"SMOKE_FLOW",
|
||||
ICON_FORCE_SMOKEFLOW,
|
||||
"Smoke Flow",
|
||||
"Create a force based on smoke simulation air flow"},
|
||||
{PFIELD_FLUIDFLOW,
|
||||
"FLUID_FLOW",
|
||||
ICON_FORCE_FLUIDFLOW,
|
||||
"Fluid Flow",
|
||||
"Create a force based on fluid simulation velocities"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
@@ -159,7 +159,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
||||
ctx->object,
|
||||
mmd->domain->effector_weights,
|
||||
true,
|
||||
PFIELD_SMOKEFLOW,
|
||||
PFIELD_FLUIDFLOW,
|
||||
"Fluid Force Field");
|
||||
|
||||
if (mmd->domain->guide_parent != NULL) {
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
@@ -177,7 +178,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
|
||||
BLI_assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
/* TODO(jbakker): Dualcon crashes when run in parallel. Could be related to incorrect
|
||||
* input data or that the library isn't thread safe. This was identified when changing the task
|
||||
* isolations during T76553. */
|
||||
static ThreadMutex dualcon_mutex = BLI_MUTEX_INITIALIZER;
|
||||
BLI_mutex_lock(&dualcon_mutex);
|
||||
output = dualcon(&input,
|
||||
dualcon_alloc_output,
|
||||
dualcon_add_vert,
|
||||
@@ -188,6 +193,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
|
||||
rmd->hermite_num,
|
||||
rmd->scale,
|
||||
rmd->depth);
|
||||
BLI_mutex_unlock(&dualcon_mutex);
|
||||
|
||||
result = output->mesh;
|
||||
MEM_freeN(output);
|
||||
}
|
||||
|
@@ -45,9 +45,18 @@ static int node_shader_gpu_output_material(GPUMaterial *mat,
|
||||
GPUNodeStack *in,
|
||||
GPUNodeStack *out)
|
||||
{
|
||||
GPUNodeLink *outlink;
|
||||
GPUNodeLink *outlink, *alpha_threshold_link;
|
||||
|
||||
GPU_stack_link(mat, node, "node_output_material", in, out, &outlink);
|
||||
Material *ma = GPU_material_get_material(mat);
|
||||
if (ma && ma->blend_method == MA_BM_CLIP) {
|
||||
alpha_threshold_link = GPU_uniform(&ma->alpha_threshold);
|
||||
}
|
||||
else {
|
||||
static float no_alpha_threshold = -1.0f;
|
||||
alpha_threshold_link = GPU_uniform(&no_alpha_threshold);
|
||||
}
|
||||
|
||||
GPU_stack_link(mat, node, "node_output_material", in, out, alpha_threshold_link, &outlink);
|
||||
GPU_material_output_link(mat, outlink);
|
||||
|
||||
return true;
|
||||
|
@@ -870,6 +870,8 @@ void WM_generic_callback_free(struct wmGenericCallback *callback);
|
||||
|
||||
void WM_generic_user_data_free(struct wmGenericUserData *user_data);
|
||||
|
||||
bool WM_region_use_viewport(struct ScrArea *area, struct ARegion *region);
|
||||
|
||||
#ifdef WITH_XR_OPENXR
|
||||
/* wm_xr.c */
|
||||
bool WM_xr_session_exists(const wmXrData *xr);
|
||||
|
@@ -293,7 +293,7 @@ static bool wm_region_use_viewport_by_type(short space_type, short region_type)
|
||||
return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE) && region_type == RGN_TYPE_WINDOW);
|
||||
}
|
||||
|
||||
static bool wm_region_use_viewport(ScrArea *area, ARegion *region)
|
||||
bool WM_region_use_viewport(ScrArea *area, ARegion *region)
|
||||
{
|
||||
return wm_region_use_viewport_by_type(area->spacetype, region->regiontype);
|
||||
}
|
||||
@@ -658,7 +658,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
if (region->visible && region->do_draw) {
|
||||
CTX_wm_region_set(C, region);
|
||||
bool use_viewport = wm_region_use_viewport(area, region);
|
||||
bool use_viewport = WM_region_use_viewport(area, region);
|
||||
|
||||
if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) {
|
||||
wm_draw_region_buffer_create(region, true, use_viewport);
|
||||
@@ -1042,7 +1042,7 @@ void WM_draw_region_free(ARegion *region, bool hide)
|
||||
void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region)
|
||||
{
|
||||
/* Function for redraw timer benchmark. */
|
||||
bool use_viewport = wm_region_use_viewport(area, region);
|
||||
bool use_viewport = WM_region_use_viewport(area, region);
|
||||
wm_draw_region_buffer_create(region, false, use_viewport);
|
||||
wm_draw_region_bind(region, 0);
|
||||
ED_region_do_draw(C, region);
|
||||
|
@@ -61,18 +61,28 @@ void WM_event_print(const wmEvent *event)
|
||||
const char *unknown = "UNKNOWN";
|
||||
const char *type_id = unknown;
|
||||
const char *val_id = unknown;
|
||||
const char *prev_type_id = unknown;
|
||||
const char *prev_val_id = unknown;
|
||||
|
||||
RNA_enum_identifier(rna_enum_event_type_items, event->type, &type_id);
|
||||
RNA_enum_identifier(rna_enum_event_value_items, event->val, &val_id);
|
||||
|
||||
RNA_enum_identifier(rna_enum_event_type_items, event->prevtype, &prev_type_id);
|
||||
RNA_enum_identifier(rna_enum_event_value_items, event->prevval, &prev_val_id);
|
||||
|
||||
printf(
|
||||
"wmEvent type:%d / %s, val:%d / %s,\n"
|
||||
" prev_type:%d / %s, prev_val:%d / %s,\n"
|
||||
" shift:%d, ctrl:%d, alt:%d, oskey:%d, keymodifier:%d, is_repeat:%d,\n"
|
||||
" mouse:(%d,%d), ascii:'%c', utf8:'%.*s', pointer:%p\n",
|
||||
event->type,
|
||||
type_id,
|
||||
event->val,
|
||||
val_id,
|
||||
event->prevtype,
|
||||
prev_type_id,
|
||||
event->prevval,
|
||||
prev_val_id,
|
||||
event->shift,
|
||||
event->ctrl,
|
||||
event->alt,
|
||||
|
@@ -2952,7 +2952,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
else {
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
if (win) {
|
||||
if (ISKEYMODIFIER(win->eventstate->prevtype)) {
|
||||
if (ISKEYMODIFIER(win->eventstate->type)) {
|
||||
win->eventstate->check_click = 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user