Drawing API: shgroup_instance and shgroup_instance_alpha clarification
shgroup_instance_alpha was getting a color[4] but would only use the alpha defined upon creation of the shading group. This was very limiting since it wouldn't allow for different instances to have different alpha values. Patch made with Clément Foucault (he made the code of it, while I fixed all the parts of the code that were relying on shgroup_instance_alpha.
This commit is contained in:
@@ -444,18 +444,18 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct GPUBatch *geom)
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
|
||||
|
||||
DRW_shgroup_instance_format(g_formats.instance_sized, {
|
||||
{"color", DRW_ATTRIB_FLOAT, 3},
|
||||
{"color", DRW_ATTRIB_FLOAT, 4},
|
||||
{"size", DRW_ATTRIB_FLOAT, 1},
|
||||
{"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_sized);
|
||||
DRW_shgroup_uniform_float_copy(grp, "alpha", 1.0f);
|
||||
DRW_shgroup_state_disable(grp, DRW_STATE_BLEND);
|
||||
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *shgroup_instance_alpha(DRWPass *pass, struct GPUBatch *geom, float alpha)
|
||||
DRWShadingGroup *shgroup_instance_alpha(DRWPass *pass, struct GPUBatch *geom)
|
||||
{
|
||||
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
|
||||
|
||||
@@ -466,7 +466,6 @@ DRWShadingGroup *shgroup_instance_alpha(DRWPass *pass, struct GPUBatch *geom, fl
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_sized);
|
||||
DRW_shgroup_uniform_float_copy(grp, "alpha", alpha);
|
||||
|
||||
return grp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user