diff options
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_materials.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_materials.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 16fcda54253..2219f5cf2dd 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -85,6 +85,7 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, + bool is_tiled, const WORKBENCH_ColorOverride color_override) { char *str = NULL; @@ -102,6 +103,7 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, use_textures = false; use_vertex_colors = true; is_hair = false; + is_tiled = false; break; case WORKBENCH_COLOR_OVERRIDE_OFF: break; @@ -151,6 +153,9 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, if (is_hair) { BLI_dynstr_append(ds, "#define HAIR_SHADER\n"); } + if (use_textures && is_tiled) { + BLI_dynstr_append(ds, "#define TEXTURE_IMAGE_ARRAY\n"); + } str = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); @@ -211,6 +216,7 @@ int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd) int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, + bool is_tiled, const WORKBENCH_ColorOverride color_override) { bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color; @@ -225,6 +231,7 @@ int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, case WORKBENCH_COLOR_OVERRIDE_VERTEX: use_textures = false; use_vertex_colors = true; + is_tiled = false; break; case WORKBENCH_COLOR_OVERRIDE_OFF: break; @@ -239,6 +246,7 @@ int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, SET_FLAG_FROM_TEST(index, MATCAP_ENABLED(wpd), 1 << 4); SET_FLAG_FROM_TEST(index, use_textures, 1 << 5); SET_FLAG_FROM_TEST(index, use_vertex_colors, 1 << 6); + SET_FLAG_FROM_TEST(index, is_tiled && use_textures, 1 << 7); BLI_assert(index < MAX_PREPASS_SHADERS); return index; } @@ -246,6 +254,7 @@ int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, + bool is_tiled, const WORKBENCH_ColorOverride color_override) { bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color; @@ -262,6 +271,7 @@ int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, use_textures = false; use_vertex_colors = true; is_hair = false; + is_tiled = false; break; case WORKBENCH_COLOR_OVERRIDE_OFF: break; @@ -277,6 +287,7 @@ int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, /* 1 bits SHADOWS (only facing factor) */ SET_FLAG_FROM_TEST(index, SHADOW_ENABLED(wpd), 1 << 5); SET_FLAG_FROM_TEST(index, workbench_is_specular_highlight_enabled(wpd), 1 << 6); + SET_FLAG_FROM_TEST(index, is_tiled && use_textures, 1 << 7); BLI_assert(index < MAX_ACCUM_SHADERS); return index; } @@ -352,6 +363,7 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, WORKBENCH_MaterialData *material, Object *ob, const bool deferred, + const bool is_tiled, const int interp) { if (deferred && !workbench_is_matdata_pass_enabled(wpd)) { @@ -362,8 +374,18 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, const bool use_texture = (V3D_SHADING_TEXTURE_COLOR == workbench_material_determine_color_type( wpd, material->ima, ob, false)); if (use_texture) { - GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D); - DRW_shgroup_uniform_texture(grp, "image", tex); + if (is_tiled) { + GPUTexture *array_tex = GPU_texture_from_blender( + material->ima, material->iuser, GL_TEXTURE_2D_ARRAY); + GPUTexture *data_tex = GPU_texture_from_blender( + material->ima, material->iuser, GL_TEXTURE_1D_ARRAY); + DRW_shgroup_uniform_texture(grp, "image_tile_array", array_tex); + DRW_shgroup_uniform_texture(grp, "image_tile_data", data_tex); + } + else { + GPUTexture *tex = GPU_texture_from_blender(material->ima, material->iuser, GL_TEXTURE_2D); + DRW_shgroup_uniform_texture(grp, "image", tex); + } DRW_shgroup_uniform_bool_copy( grp, "imagePremultiplied", (material->ima->alpha_mode == IMA_ALPHA_PREMUL)); DRW_shgroup_uniform_bool_copy(grp, "imageNearest", (interp == SHD_INTERP_CLOSEST)); |