DRW: Rename DRW_shgroup_uniform_vec4_array_copy to mat4_copy
This function was not used for anything other than mat4. This was because of a limitation of the DRW module/ This makes it cleaner for the GLSL and also less tempting to use it for other unconventional purpose.
This commit is contained in:
@@ -756,7 +756,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
|
||||
uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z;
|
||||
DRWShadingGroup *grp = DRW_shgroup_create_sub(vedata->stl->pd->extra_grid_grp);
|
||||
DRW_shgroup_uniform_vec4_array_copy(grp, "gridModelMatrix", instdata.mat, 4);
|
||||
DRW_shgroup_uniform_mat4_copy(grp, "gridModelMatrix", instdata.mat);
|
||||
DRW_shgroup_call_procedural_points(grp, NULL, cell_count);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -148,7 +148,7 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part
|
||||
|
||||
const bool use_coloring = true;
|
||||
DRWShadingGroup *shgrp = DRW_shgroup_create_sub(pd->wires_hair_grp[is_xray][use_coloring]);
|
||||
DRW_shgroup_uniform_vec4_array_copy(shgrp, "hairDupliMatrix", dupli_mat, 4);
|
||||
DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", dupli_mat);
|
||||
DRW_shgroup_call_no_cull(shgrp, hairs, ob);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
uniform depth2D depthBuffer;
|
||||
uniform vec4 gridModelMatrix[4];
|
||||
uniform mat4 gridModelMatrix;
|
||||
uniform bool isTransform;
|
||||
|
||||
out vec4 finalColor;
|
||||
@@ -27,8 +27,7 @@ vec4 color_from_id(float color_id)
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 model_mat = mat4(
|
||||
gridModelMatrix[0], gridModelMatrix[1], gridModelMatrix[2], gridModelMatrix[3]);
|
||||
mat4 model_mat = gridModelMatrix;
|
||||
model_mat[0][3] = model_mat[1][3] = model_mat[2][3] = 0.0;
|
||||
model_mat[3][3] = 1.0;
|
||||
float color_id = gridModelMatrix[3].w;
|
||||
|
||||
@@ -6,7 +6,7 @@ uniform bool isTransform;
|
||||
uniform bool isObjectColor;
|
||||
uniform bool isRandomColor;
|
||||
uniform bool isHair;
|
||||
uniform vec4 hairDupliMatrix[4];
|
||||
uniform mat4 hairDupliMatrix;
|
||||
|
||||
in vec3 pos;
|
||||
in vec3 nor;
|
||||
@@ -94,9 +94,7 @@ void main()
|
||||
vec3 wpos = point_object_to_world(pos);
|
||||
|
||||
if (isHair) {
|
||||
mat4 obmat = mat4(
|
||||
hairDupliMatrix[0], hairDupliMatrix[1], hairDupliMatrix[2], hairDupliMatrix[3]);
|
||||
|
||||
mat4 obmat = hairDupliMatrix;
|
||||
wpos = (obmat * vec4(pos, 1.0)).xyz;
|
||||
wnor = -normalize(mat3(obmat) * nor);
|
||||
}
|
||||
|
||||
@@ -634,10 +634,9 @@ void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name,
|
||||
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value);
|
||||
void DRW_shgroup_uniform_vec3_copy(DRWShadingGroup *shgroup, const char *name, const float *value);
|
||||
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value);
|
||||
void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float (*value)[4],
|
||||
int arraysize);
|
||||
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float (*value)[4]);
|
||||
void DRW_shgroup_vertex_buffer_ex(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
struct GPUVertBuf *vertex_buffer DRW_DEBUG_FILE_LINE_ARGS);
|
||||
|
||||
@@ -305,7 +305,7 @@ DRWShadingGroup *DRW_shgroup_hair_create_sub(Object *object,
|
||||
DRW_shgroup_uniform_int(shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
|
||||
DRW_shgroup_uniform_int_copy(shgrp, "hairThicknessRes", thickness_res);
|
||||
DRW_shgroup_uniform_float_copy(shgrp, "hairRadShape", hair_rad_shape);
|
||||
DRW_shgroup_uniform_vec4_array_copy(shgrp, "hairDupliMatrix", dupli_mat, 4);
|
||||
DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", dupli_mat);
|
||||
DRW_shgroup_uniform_float_copy(shgrp, "hairRadRoot", hair_rad_root);
|
||||
DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", hair_rad_tip);
|
||||
DRW_shgroup_uniform_bool_copy(shgrp, "hairCloseTip", hair_close_tip);
|
||||
|
||||
@@ -485,10 +485,9 @@ void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, c
|
||||
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT_COPY, value, 4, 1);
|
||||
}
|
||||
|
||||
void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float (*value)[4],
|
||||
int arraysize)
|
||||
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup,
|
||||
const char *name,
|
||||
const float (*value)[4])
|
||||
{
|
||||
int location = GPU_shader_get_uniform(shgroup->shader, name);
|
||||
|
||||
@@ -502,9 +501,8 @@ void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup,
|
||||
* All entries from the same array share the same base location,
|
||||
* and array-size used to determine the number of elements
|
||||
* copied in draw_update_uniforms. */
|
||||
for (int i = 0; i < arraysize; i++) {
|
||||
drw_shgroup_uniform_create_ex(
|
||||
shgroup, location, DRW_UNIFORM_FLOAT_COPY, &value[i], 0, 4, arraysize);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
drw_shgroup_uniform_create_ex(shgroup, location, DRW_UNIFORM_FLOAT_COPY, &value[i], 0, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -613,8 +613,7 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
|
||||
memcpy(&mat4_stack[array_index], uni->fvalue, sizeof(float) * uni->length);
|
||||
/* Flush array data to shader. */
|
||||
if (array_index <= 0) {
|
||||
GPU_shader_uniform_vector(
|
||||
shgroup->shader, uni->location, uni->length, uni->arraysize, mat4_stack);
|
||||
GPU_shader_uniform_vector(shgroup->shader, uni->location, 16, 1, mat4_stack);
|
||||
array_uniform_loc = -1;
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -29,7 +29,7 @@ uniform float hairRadTip = 0.0;
|
||||
uniform float hairRadShape = 0.5;
|
||||
uniform bool hairCloseTip = true;
|
||||
|
||||
uniform vec4 hairDupliMatrix[4];
|
||||
uniform mat4 hairDupliMatrix;
|
||||
|
||||
/* Strand batch offset when used in compute shaders. */
|
||||
uniform int hairStrandOffset = 0;
|
||||
@@ -192,9 +192,7 @@ void hair_get_pos_tan_binor_time(bool is_persp,
|
||||
wtan = wpos - texelFetch(hairPointBuffer, id - 1).point_position;
|
||||
}
|
||||
|
||||
mat4 obmat = mat4(
|
||||
hairDupliMatrix[0], hairDupliMatrix[1], hairDupliMatrix[2], hairDupliMatrix[3]);
|
||||
|
||||
mat4 obmat = hairDupliMatrix;
|
||||
wpos = (obmat * vec4(wpos, 1.0)).xyz;
|
||||
wtan = -normalize(mat3(obmat) * wtan);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ GPU_SHADER_CREATE_INFO(draw_hair_refine_compute)
|
||||
.sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer")
|
||||
.sampler(1, ImageType::UINT_BUFFER, "hairStrandBuffer")
|
||||
.sampler(2, ImageType::UINT_BUFFER, "hairStrandSegBuffer")
|
||||
.push_constant(Type::VEC4, "hairDupliMatrix", 4)
|
||||
.push_constant(Type::MAT4, "hairDupliMatrix")
|
||||
.push_constant(Type::BOOL, "hairCloseTip")
|
||||
.push_constant(Type::FLOAT, "hairRadShape")
|
||||
.push_constant(Type::FLOAT, "hairRadTip")
|
||||
|
||||
@@ -102,7 +102,7 @@ GPU_SHADER_CREATE_INFO(draw_hair)
|
||||
.push_constant(Type::FLOAT, "hairRadShape")
|
||||
.push_constant(Type::BOOL, "hairCloseTip")
|
||||
.push_constant(Type::INT, "hairStrandOffset")
|
||||
.push_constant(Type::VEC4, "hairDupliMatrix", 4)
|
||||
.push_constant(Type::MAT4, "hairDupliMatrix")
|
||||
.additional_info("draw_modelmat", "draw_resource_id");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(draw_pointcloud)
|
||||
|
||||
Reference in New Issue
Block a user