DRW: Remove screen_vecs
These were only a normalized copy of the XY axes of the inverse viewmat. But since the viewmatrix is always normalized we can use it directly.
This commit is contained in:
@@ -329,7 +329,6 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex);
|
||||
DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
|
||||
DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
|
||||
DRW_shgroup_uniform_vec3(grp, "screen_vecs", DRW_viewport_screenvecs_get(), 2);
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
grp, "sphere_size", scene_eval->eevee.gi_cubemap_draw_size * 0.5f);
|
||||
/* TODO(fclem): get rid of those UBO. */
|
||||
@@ -353,7 +352,6 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
|
||||
DRW_shgroup_uniform_vec3(shgrp, "increment_x", egrid->increment_x, 1);
|
||||
DRW_shgroup_uniform_vec3(shgrp, "increment_y", egrid->increment_y, 1);
|
||||
DRW_shgroup_uniform_vec3(shgrp, "increment_z", egrid->increment_z, 1);
|
||||
DRW_shgroup_uniform_vec3(shgrp, "screen_vecs", DRW_viewport_screenvecs_get(), 2);
|
||||
DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex);
|
||||
DRW_shgroup_uniform_float_copy(
|
||||
shgrp, "sphere_size", scene_eval->eevee.gi_irradiance_draw_size * 0.5f);
|
||||
|
||||
@@ -15,7 +15,6 @@ layout(std140) uniform probe_block
|
||||
};
|
||||
|
||||
uniform float sphere_size;
|
||||
uniform vec3 screen_vecs[2];
|
||||
|
||||
flat out int pid;
|
||||
out vec2 quadCoord;
|
||||
@@ -36,7 +35,8 @@ void main()
|
||||
quadCoord = pos[vert_id];
|
||||
|
||||
vec3 ws_location = probes_data[pid].position_type.xyz;
|
||||
vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
|
||||
vec3 screen_pos = ViewMatrixInverse[0].xyz * quadCoord.x +
|
||||
ViewMatrixInverse[1].xyz * quadCoord.y;
|
||||
ws_location += screen_pos * sphere_size;
|
||||
|
||||
gl_Position = ProjectionMatrix * (ViewMatrix * vec4(ws_location, 1.0));
|
||||
|
||||
@@ -8,7 +8,6 @@ uniform vec3 corner;
|
||||
uniform vec3 increment_x;
|
||||
uniform vec3 increment_y;
|
||||
uniform vec3 increment_z;
|
||||
uniform vec3 screen_vecs[2];
|
||||
|
||||
flat out int cellOffset;
|
||||
out vec2 quadCoord;
|
||||
@@ -39,7 +38,8 @@ void main()
|
||||
increment_z * ls_cell_location.z);
|
||||
|
||||
quadCoord = pos[vert_id];
|
||||
vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
|
||||
vec3 screen_pos = ViewMatrixInverse[0].xyz * quadCoord.x +
|
||||
ViewMatrixInverse[1].xyz * quadCoord.y;
|
||||
ws_cell_location += screen_pos * sphere_size;
|
||||
|
||||
gl_Position = ProjectionMatrix * (ViewMatrix * vec4(ws_cell_location, 1.0));
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
void main()
|
||||
{
|
||||
mat3 imat = mat3(ModelMatrixInverse);
|
||||
vec3 right = normalize(imat * screenVecs[0].xyz);
|
||||
vec3 up = normalize(imat * screenVecs[1].xyz);
|
||||
vec3 right = normalize(imat * ViewMatrixInverse[0].xyz);
|
||||
vec3 up = normalize(imat * ViewMatrixInverse[1].xyz);
|
||||
vec3 screen_pos = (right * pos.x + up * pos.z) * size;
|
||||
vec4 pos_4d = ModelMatrix * vec4(local_pos + screen_pos, 1.0);
|
||||
gl_Position = drw_view.winmat * (drw_view.viewmat * pos_4d);
|
||||
|
||||
@@ -7,7 +7,7 @@ void main()
|
||||
finalColor = colorLight;
|
||||
|
||||
/* Relative to DPI scaling. Have constant screen size. */
|
||||
vec3 screen_pos = screenVecs[0].xyz * pos.x + screenVecs[1].xyz * pos.y;
|
||||
vec3 screen_pos = ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y;
|
||||
vec3 p = inst_pos;
|
||||
p.z *= (pos.z == 0.0) ? 0.0 : 1.0;
|
||||
float screen_size = mul_project_m4_v3_zfac(p) * sizePixel;
|
||||
|
||||
@@ -171,14 +171,14 @@ void main()
|
||||
vec3 world_pos;
|
||||
if ((vclass & VCLASS_SCREENSPACE) != 0) {
|
||||
/* Relative to DPI scaling. Have constant screen size. */
|
||||
vec3 screen_pos = screenVecs[0].xyz * vpos.x + screenVecs[1].xyz * vpos.y;
|
||||
vec3 screen_pos = ViewMatrixInverse[0].xyz * vpos.x + ViewMatrixInverse[1].xyz * vpos.y;
|
||||
vec3 p = (obmat * vec4(vofs, 1.0)).xyz;
|
||||
float screen_size = mul_project_m4_v3_zfac(p) * sizePixel;
|
||||
world_pos = p + screen_pos * screen_size;
|
||||
}
|
||||
else if ((vclass & VCLASS_SCREENALIGNED) != 0) {
|
||||
/* World sized, camera facing geometry. */
|
||||
vec3 screen_pos = screenVecs[0].xyz * vpos.x + screenVecs[1].xyz * vpos.y;
|
||||
vec3 screen_pos = ViewMatrixInverse[0].xyz * vpos.x + ViewMatrixInverse[1].xyz * vpos.y;
|
||||
world_pos = (obmat * vec4(vofs, 1.0)).xyz + screen_pos;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -95,9 +95,9 @@ void main()
|
||||
}
|
||||
|
||||
if (flag_test(grid_flag, SHOW_GRID)) {
|
||||
/* Using `max(dot(dFdxPos, screenVecs[0]), dot(dFdyPos, screenVecs[1]))`
|
||||
/* Using `max(dot(dFdxPos, ViewMatrixInverse[0]), dot(dFdyPos, ViewMatrixInverse[1]))`
|
||||
* would be more accurate, but not really necessary. */
|
||||
float grid_res = dot(dFdxPos, screenVecs[0].xyz);
|
||||
float grid_res = dot(dFdxPos, ViewMatrixInverse[0].xyz);
|
||||
|
||||
/* The grid begins to appear when it comprises 4 pixels. */
|
||||
grid_res *= 4;
|
||||
|
||||
@@ -28,7 +28,7 @@ void main()
|
||||
|
||||
if ((vclass & VCLASS_SCREENALIGNED) != 0) {
|
||||
/* World sized, camera facing geometry. */
|
||||
world_pos += (screenVecs[0].xyz * pos.x + screenVecs[1].xyz * pos.y) * draw_size;
|
||||
world_pos += (ViewMatrixInverse[0].xyz * pos.x + ViewMatrixInverse[1].xyz * pos.y) * draw_size;
|
||||
}
|
||||
else {
|
||||
world_pos += rotate(pos, part_rot) * draw_size;
|
||||
|
||||
@@ -738,7 +738,6 @@ void DRW_culling_frustum_planes_get(const DRWView *view, float planes[6][4]);
|
||||
|
||||
const float *DRW_viewport_size_get(void);
|
||||
const float *DRW_viewport_invert_size_get(void);
|
||||
const float *DRW_viewport_screenvecs_get(void);
|
||||
const float *DRW_viewport_pixelsize_get(void);
|
||||
|
||||
struct DefaultFramebufferList *DRW_viewport_framebuffer_list_get(void);
|
||||
|
||||
@@ -178,11 +178,6 @@ void DRW_globals_update(void)
|
||||
gb->size_edge = U.pixelsize * (1.0f / 2.0f); /* TODO: Theme. */
|
||||
gb->size_edge_fix = U.pixelsize * (0.5f + 2.0f * (2.0f * (gb->size_edge * (float)M_SQRT1_2)));
|
||||
|
||||
const float(*screen_vecs)[3] = (float(*)[3])DRW_viewport_screenvecs_get();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
copy_v3_v3(gb->screen_vecs[i], screen_vecs[i]);
|
||||
}
|
||||
|
||||
gb->pixel_fac = *DRW_viewport_pixelsize_get();
|
||||
|
||||
/* Deprecated, use drw_view.viewport_size instead */
|
||||
|
||||
@@ -124,8 +124,7 @@ struct GlobalsUboStorage {
|
||||
float4 color_uv_shadow;
|
||||
|
||||
/* NOTE: Put all color before #UBO_LAST_COLOR. */
|
||||
float4 screen_vecs[2]; /* Padded as vec4. */
|
||||
float4 size_viewport; /* Packed as vec4. */
|
||||
float4 size_viewport; /* Packed as vec4. */
|
||||
|
||||
/* Pack individual float at the end of the buffer to avoid alignment errors */
|
||||
float size_pixel, pixel_fac;
|
||||
@@ -228,7 +227,6 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
|
||||
# define colorFaceBack globalsBlock.color_face_back
|
||||
# define colorFaceFront globalsBlock.color_face_front
|
||||
# define colorUVShadow globalsBlock.color_uv_shadow
|
||||
# define screenVecs globalsBlock.screen_vecs
|
||||
# define sizeViewport globalsBlock.size_viewport.xy
|
||||
# define sizePixel globalsBlock.size_pixel
|
||||
# define pixelFac globalsBlock.pixel_fac
|
||||
|
||||
@@ -298,10 +298,6 @@ const float *DRW_viewport_invert_size_get(void)
|
||||
return DST.inv_size;
|
||||
}
|
||||
|
||||
const float *DRW_viewport_screenvecs_get(void)
|
||||
{
|
||||
return &DST.screenvecs[0][0];
|
||||
}
|
||||
|
||||
const float *DRW_viewport_pixelsize_get(void)
|
||||
{
|
||||
@@ -561,9 +557,6 @@ static void drw_manager_init(DRWManager *dst, GPUViewport *viewport, const int s
|
||||
draw_unit_state_create();
|
||||
|
||||
if (rv3d != NULL) {
|
||||
normalize_v3_v3(dst->screenvecs[0], rv3d->viewinv[0]);
|
||||
normalize_v3_v3(dst->screenvecs[1], rv3d->viewinv[1]);
|
||||
|
||||
dst->pixsize = rv3d->pixsize;
|
||||
dst->view_default = DRW_view_create(rv3d->viewmat, rv3d->winmat, NULL, NULL, NULL);
|
||||
|
||||
@@ -594,9 +587,6 @@ static void drw_manager_init(DRWManager *dst, GPUViewport *viewport, const int s
|
||||
dst->view_previous = NULL;
|
||||
}
|
||||
else {
|
||||
zero_v3(dst->screenvecs[0]);
|
||||
zero_v3(dst->screenvecs[1]);
|
||||
|
||||
dst->pixsize = 1.0f;
|
||||
dst->view_default = NULL;
|
||||
dst->view_active = NULL;
|
||||
|
||||
@@ -598,7 +598,6 @@ typedef struct DRWManager {
|
||||
struct GPUFrameBuffer *default_framebuffer;
|
||||
float size[2];
|
||||
float inv_size[2];
|
||||
float screenvecs[2][3];
|
||||
float pixsize;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -107,7 +107,6 @@ layout(std140) uniform globalsBlock
|
||||
|
||||
vec4 colorUVShadow;
|
||||
|
||||
vec4 screenVecs[2];
|
||||
vec4 sizeViewport; /* Inverted size in zw. */
|
||||
|
||||
float sizePixel; /* This one is for DPI scaling. */
|
||||
|
||||
Reference in New Issue
Block a user