Page MenuHome
Paste P1491

Masterwork From Distant Lands
ActivePublic

Authored by Clément Foucault (fclem) on Sun, Jun 28, 8:56 PM.
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index 9d6105af8fb..7744f54cbd8 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -216,7 +216,11 @@ static void workbench_cache_hair_populate(WORKBENCH_PrivateData *wpd,
workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, interp) :
workbench_material_hair_setup(wpd, ob, matnr, color_type);
- DRW_shgroup_hair_create_sub(ob, psys, md, grp);
+ grp = DRW_shgroup_hair_create_sub(ob, psys, md, grp);
+
+ if (use_texpaint_mode || (color_type == V3D_SHADING_TEXTURE_COLOR)) {
+ workbench_image_hair_setup_post(wpd, ob, matnr, use_texpaint_mode, ima, NULL, interp, grp);
+ }
}
/**
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 0b7d313342b..00638aa9f61 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -283,14 +283,62 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
DRWShadingGroup *grp = (tex_tile_data) ? prepass->image_tiled_shgrp : prepass->image_shgrp;
*grp_tex = grp = DRW_shgroup_create_sub(grp);
- if (tex_tile_data) {
- DRW_shgroup_uniform_texture_persistent(grp, "imageTileArray", tex);
- DRW_shgroup_uniform_texture_persistent(grp, "imageTileData", tex_tile_data);
- }
- else {
- DRW_shgroup_uniform_texture_persistent(grp, "imageTexture", tex);
+ if (!hair) {
+ if (tex_tile_data) {
+ DRW_shgroup_uniform_texture(grp, "imageTileArray", tex);
+ DRW_shgroup_uniform_texture(grp, "imageTileData", tex_tile_data);
+ }
+ else {
+ DRW_shgroup_uniform_texture(grp, "imageTexture", tex);
+ }
}
DRW_shgroup_uniform_bool_copy(grp, "imagePremult", (ima && ima->alpha_mode == IMA_ALPHA_PREMUL));
DRW_shgroup_uniform_bool_copy(grp, "imageNearest", (interp == SHD_INTERP_CLOSEST));
return grp;
}
+
+/* Workaround for T77759 only present in LTS branch. */
+void workbench_image_hair_setup_post(WORKBENCH_PrivateData *wpd,
+ Object *ob,
+ int mat_nr,
+ const bool use_texpaint_mode,
+ Image *ima,
+ ImageUser *iuser,
+ int interp,
+ DRWShadingGroup *grp)
+{
+ GPUTexture *tex = NULL, *tex_tile_data = NULL;
+
+ if (!use_texpaint_mode) {
+ workbench_material_get_image(ob, mat_nr, &ima, &iuser, &interp);
+ if (ima == NULL) {
+ return;
+ }
+ }
+
+ if (ima == NULL) {
+ workbench_material_get_image(ob, mat_nr, &ima, &iuser, &interp);
+ }
+
+ if (ima) {
+ if (ima->source == IMA_SRC_TILED) {
+ tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D_ARRAY);
+ tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_1D_ARRAY);
+ }
+ else {
+ tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D);
+ }
+ }
+
+ if (tex == NULL) {
+ tex = wpd->dummy_image_tx;
+ }
+
+ if (tex_tile_data) {
+ DRW_shgroup_uniform_texture(grp, "imageTileArray", tex);
+ DRW_shgroup_uniform_texture(grp, "imageTileData", tex_tile_data);
+ }
+ else {
+ DRW_shgroup_uniform_texture(grp, "imageTexture", tex);
+ }
+}
\ No newline at end of file
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 967bdf9bae0..204d2e995c0 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -464,6 +464,14 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
ImageUser *iuser,
int interp,
bool hair);
+void workbench_image_hair_setup_post(WORKBENCH_PrivateData *wpd,
+ Object *ob,
+ int mat_nr,
+ const bool use_texpaint_mode,
+ Image *ima,
+ ImageUser *iuser,
+ int interp,
+ DRWShadingGroup *grp);
#define workbench_material_setup(wpd, ob, mat_nr, color_type, r_transp) \
workbench_material_setup_ex(wpd, ob, mat_nr, color_type, false, r_transp)