diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-10-12 13:42:20 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-10-12 13:42:20 +0300 |
commit | a5a4dd20905725d5f26e5fc9f181145128d6d358 (patch) | |
tree | 3a66fabd9c901d49688591df3f8a679a08df1c06 /source/blender/gpu/shaders | |
parent | 82d9617dab040400a13f142949b55c55a8491ce9 (diff) |
Fixed some issues when removing unused tiles.
Diffstat (limited to 'source/blender/gpu/shaders')
3 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh b/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh index 1d7ca8dffb5..1428733c5b5 100644 --- a/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh +++ b/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh @@ -14,7 +14,7 @@ GPU_SHADER_CREATE_INFO(sculpt_paint_sub_tiles) GPU_SHADER_CREATE_INFO(sculpt_paint_image_compute) .local_group_size(1, 1, 1) - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "paint_tiles_img") + .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "paint_tiles_img") .storage_buf(1, Qualifier::READ, "PackedPixelRow", "pixel_row_buf[]") .storage_buf(2, Qualifier::READ, "TrianglePaintInput", "paint_input[]") .storage_buf(3, Qualifier::READ, "vec3", "vert_coord_buf[]") @@ -29,13 +29,26 @@ GPU_SHADER_CREATE_INFO(sculpt_paint_image_compute) GPU_SHADER_CREATE_INFO(sculpt_paint_image_merge_compute) .local_group_size(1, 1, 1) - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_3D, "paint_tiles_img") + .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "paint_tiles_img") .image(1, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "texture_img") + .push_constant(Type::INT, "layer_id") .compute_source("sculpt_paint_image_merge_comp.glsl") .typedef_source("GPU_sculpt_shader_shared.h") .additional_info("sculpt_paint_sub_tiles") .do_static_compilation(true); +/* +GPU_SHADER_CREATE_INFO(sculpt_paint_image_init_tile_compute) + .local_group_size(1, 1, 1) + .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "paint_tiles_img") + .image(1, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "texture_img") + .push_constant(Type::INT, "layer_id") + .compute_source("sculpt_paint_image_merge_comp.glsl") + .typedef_source("GPU_sculpt_shader_shared.h") + .additional_info("sculpt_paint_sub_tiles") + .do_static_compilation(true); +*/ + /* -------------------------------------------------------------------- */ /** \name Brush variations * \{ */ diff --git a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_merge_comp.glsl b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_merge_comp.glsl index 406d83633b0..b3ff3ac3ff3 100644 --- a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_merge_comp.glsl +++ b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_merge_comp.glsl @@ -2,10 +2,12 @@ void main() { - ivec2 coord_out = ivec2(gl_GlobalInvocationID.xy); PaintTileData paint_tile; - ivec3 coord_in = paint_tile_coord_from_udim(1001, coord_out, paint_tile); + paint_tile_get_layer(layer_id, paint_tile); + ivec3 coord_in = ivec3(gl_GlobalInvocationID.xy, layer_id); vec4 paint_color = imageLoad(paint_tiles_img, coord_in); paint_color.a = 1.0; + + ivec2 coord_out = paint_tile_coord_to_udim(paint_tile, coord_in.xy); imageStore(texture_img, coord_out, paint_color); }
\ No newline at end of file diff --git a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_tile_lib.glsl b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_tile_lib.glsl index 1896535ec20..c45664dd97c 100644 --- a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_tile_lib.glsl +++ b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_tile_lib.glsl @@ -16,6 +16,11 @@ bool paint_tile_search(int tile_number, ivec2 coord, out PaintTileData r_paint_t return false; } +void paint_tile_get_layer(int layer_id, out PaintTileData r_paint_tile) +{ + r_paint_tile = paint_tile_buf[layer_id]; +} + ivec3 paint_tile_coord_from_udim(int tile_number, ivec2 coord, out PaintTileData r_paint_tile) { if (paint_tile_search(tile_number, coord, r_paint_tile)) { @@ -24,3 +29,8 @@ ivec3 paint_tile_coord_from_udim(int tile_number, ivec2 coord, out PaintTileData return ivec3(0); } + +ivec2 paint_tile_coord_to_udim(PaintTileData paint_tile, ivec2 coord) +{ + return paint_tile.sub_tile_id * ivec2(SUB_TILE_SIZE) + coord; +} |