Cleanup: Eevee: Remove custom volumetric matrix

This was the same as using the inverse obmat.
This commit is contained in:
Clément Foucault
2019-05-17 13:31:39 +02:00
parent 52669dda80
commit 2bb788d4cd
4 changed files with 7 additions and 22 deletions

View File

@@ -404,20 +404,6 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
BKE_mesh_texspace_get_reference((struct Mesh *)ob->data, NULL, &texcoloc, NULL, &texcosize);
float(*imat)[4] = ob->imat;
if ((ob->base_flag & BASE_FROM_DUPLI) != 0) {
/* TODO Remove from here and use a dedicated buffer. */
EEVEE_InstanceVolumeMatrix *ivm = (EEVEE_InstanceVolumeMatrix *)DRW_drawdata_ensure(
&ob->id,
(DrawEngineType *)EEVEE_volumes_cache_object_add,
sizeof(EEVEE_InstanceVolumeMatrix),
NULL,
NULL);
copy_m4_m4(ivm->volume_mat, ob->imat);
imat = ivm->volume_mat;
}
/* TODO(fclem) remove those "unnecessary" UBOs */
DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
@@ -426,7 +412,6 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
DRW_shgroup_uniform_mat4(grp, "volumeObjectMatrix", imat);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoLoc", texcoloc, 1);
DRW_shgroup_uniform_vec3(grp, "volumeOrcoSize", texcosize, 1);
@@ -477,7 +462,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
/* TODO Reduce to number of slices intersecting. */
/* TODO Preemptive culling. */
DRW_shgroup_call_procedural_triangles(grp, sldata->common_data.vol_tex_size[2], NULL);
DRW_shgroup_call_procedural_triangles(grp, sldata->common_data.vol_tex_size[2], ob->obmat);
vedata->stl->effects->enabled_effects |= (EFFECT_VOLUMETRIC | EFFECT_POST_BUFFER);
}

View File

@@ -5,7 +5,6 @@
#define NODETREE_EXEC
#ifdef MESH_SHADER
uniform mat4 volumeObjectMatrix;
uniform vec3 volumeOrcoLoc;
uniform vec3 volumeOrcoSize;
#endif
@@ -33,9 +32,9 @@ void main()
vec3 ndc_cell = volume_to_ndc((vec3(volume_cell) + volJitter.xyz) * volInvTexSize.xyz);
viewPosition = get_view_space_from_depth(ndc_cell.xy, ndc_cell.z);
worldPosition = transform_point(ViewMatrixInverse, viewPosition);
worldPosition = point_view_to_world(viewPosition);
#ifdef MESH_SHADER
volumeObjectLocalCoord = transform_point(volumeObjectMatrix, worldPosition);
volumeObjectLocalCoord = point_world_to_object(worldPosition);
volumeObjectLocalCoord = (volumeObjectLocalCoord - volumeOrcoLoc + volumeOrcoSize) /
(volumeOrcoSize * 2.0);

View File

@@ -406,6 +406,7 @@ void DRW_shgroup_call_object_ex(DRWShadingGroup *shgroup,
#define DRW_shgroup_call_object_no_cull(shgroup, geom, ob) \
DRW_shgroup_call_object_ex(shgroup, geom, ob, true)
/* TODO(fclem) remove this when we have DRWView */
void DRW_shgroup_call_object_with_callback(DRWShadingGroup *shgroup,
struct GPUBatch *geom,
struct Object *ob,

View File

@@ -351,7 +351,7 @@ static void drw_call_state_update_matflag(DRWCallState *state,
DRWShadingGroup *shgroup,
Object *ob)
{
uint16_t new_flags = ((state->matflag ^ shgroup->matflag) & shgroup->matflag);
uchar new_flags = ((state->matflag ^ shgroup->matflag) & shgroup->matflag);
/* HACK: Here we set the matflags bit to 1 when computing the value
* so that it's not recomputed for other drawcalls.
@@ -393,8 +393,6 @@ static DRWCallState *drw_call_state_create(DRWShadingGroup *shgroup, float (*obm
state->visibility_cb = NULL;
state->matflag = 0;
drw_call_state_update_matflag(state, shgroup, ob);
/* Matrices */
if (obmat != NULL) {
copy_m4_m4(state->model, obmat);
@@ -407,6 +405,8 @@ static DRWCallState *drw_call_state_create(DRWShadingGroup *shgroup, float (*obm
unit_m4(state->model);
}
drw_call_state_update_matflag(state, shgroup, ob);
if (ob != NULL) {
float corner[3];
BoundBox *bbox = BKE_object_boundbox_get(ob);