diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-03 23:45:27 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-03 23:50:04 +0300 |
commit | 281bcc1c1dd6b786bafa2712986885c44ed482a3 (patch) | |
tree | af2ec45d2d67fce7ee94086074c05d806722fc48 /source/blender/draw/intern | |
parent | 94205e1d029511b2ab714a53d84de8c50a70fb39 (diff) |
Fix T93179: geonodes UVs and Vertex colors do not work in EEVEE
Overwriting UV map or vertex color data in Geometry nodes will move the
layers to another CustomData channel, and as such, will make attribute
lookup fail from the UVMap and Vertex Color nodes in EEVEE as the
CustomDataType will also be modified (i.e. no longer `CD_MTFACE` or
`CD_MCOL`).
As discussed in T93179, the solution is to use `CD_PROP_AUTO_FROM_NAME`
so that the render engine is able to find the attributes. This also makes
EEVEE emulate Cycles behaviour in this regard. `attr_load_uv` and
`attr_load_color` are also removed in favor of the generic attribute
API in the various GLSL shaders.
Although `CD_PROP_AUTO_FROM_NAME` is now used even for UV maps, the
active UV map is still used in case the attribute name is empty, to
preserve the old behavior.
Differential Revision: https://developer.blender.org/D13730
Diffstat (limited to 'source/blender/draw/intern')
4 files changed, 8 insertions, 33 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 0f1ab967ca5..a1c0a42ba6f 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -875,14 +875,13 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; - BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%s", attr_safe_name); BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); if (i == active_uv) { BLI_strncpy(cache->uv_layer_names[i][n++], "au", MAX_LAYER_NAME_LEN); } if (i == render_uv) { - BLI_strncpy(cache->uv_layer_names[i][n++], "u", MAX_LAYER_NAME_LEN); + BLI_strncpy(cache->uv_layer_names[i][n++], "a", MAX_LAYER_NAME_LEN); } } /* Vertex colors */ @@ -896,12 +895,7 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; - BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%s", attr_safe_name); - - /* We only do vcols auto name that are not overridden by uvs */ - if (CustomData_get_named_layer_index(&psmd->mesh_final->ldata, CD_MLOOPUV, name) == -1) { - BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); - } + BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); if (i == active_col) { BLI_strncpy(cache->col_layer_names[i][n++], "ac", MAX_LAYER_NAME_LEN); @@ -1186,11 +1180,11 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); - BLI_snprintf(uuid, sizeof(uuid), "u%s", attr_safe_name); + BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_uv) { - GPU_vertformat_alias_add(&format, "u"); + GPU_vertformat_alias_add(&format, "a"); } } @@ -1200,7 +1194,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, &psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR, i); GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); - BLI_snprintf(uuid, sizeof(uuid), "c%s", attr_safe_name); + BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_U16, 4, GPU_FETCH_FLOAT); if (i == active_col) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc index 4532f3c3710..5fb4b401ae3 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc @@ -44,14 +44,11 @@ static bool mesh_extract_uv_format_init(GPUVertFormat *format, GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* UV layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name); - GPU_vertformat_attr_add(format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - /* Auto layer name. */ BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); - GPU_vertformat_alias_add(format, attr_name); + GPU_vertformat_attr_add(format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* Active render layer name. */ if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) { - GPU_vertformat_alias_add(format, "u"); + GPU_vertformat_alias_add(format, "a"); } /* Active display layer name. */ if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc index 4cb68cad66c..e5dd025787d 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc @@ -90,7 +90,7 @@ static void init_vcol_format(GPUVertFormat *format, GPU_vertformat_safe_attr_name(ref.layer->name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* VCol layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name); + BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); GPU_vertformat_attr_add(format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); /* Active layer name. */ @@ -102,16 +102,6 @@ static void init_vcol_format(GPUVertFormat *format, if (ref.layer == render) { GPU_vertformat_alias_add(format, "c"); } - - /* Gather number of auto layers. */ - /* We only do `vcols` that are not overridden by `uvs`. */ - bool bad = ref.domain == ATTR_DOMAIN_CORNER; - bad = bad && CustomData_get_named_layer_index(cd_ldata, CD_MLOOPUV, ref.layer->name) != -1; - - if (!bad) { - BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); - GPU_vertformat_alias_add(format, attr_name); - } } } diff --git a/source/blender/draw/intern/shaders/common_attribute_lib.glsl b/source/blender/draw/intern/shaders/common_attribute_lib.glsl index 30239a84c0c..ce5e49c7f63 100644 --- a/source/blender/draw/intern/shaders/common_attribute_lib.glsl +++ b/source/blender/draw/intern/shaders/common_attribute_lib.glsl @@ -4,8 +4,6 @@ vec3 attr_load_orco(vec4 orco); vec4 attr_load_tangent(vec4 tangent); -vec3 attr_load_uv(vec3 uv); -vec4 attr_load_color(vec4 color); vec4 attr_load_vec4(vec4 attr); vec3 attr_load_vec3(vec3 attr); vec2 attr_load_vec2(vec2 attr); @@ -13,8 +11,6 @@ float attr_load_float(float attr); vec3 attr_load_orco(samplerBuffer orco); vec4 attr_load_tangent(samplerBuffer tangent); -vec3 attr_load_uv(samplerBuffer uv); -vec4 attr_load_color(samplerBuffer color); vec4 attr_load_vec4(samplerBuffer attr); vec3 attr_load_vec3(samplerBuffer attr); vec2 attr_load_vec2(samplerBuffer attr); @@ -22,8 +18,6 @@ float attr_load_float(samplerBuffer attr); vec3 attr_load_orco(sampler3D orco); vec4 attr_load_tangent(sampler3D tangent); -vec3 attr_load_uv(sampler3D attr); -vec4 attr_load_color(sampler3D tex); vec4 attr_load_vec4(sampler3D tex); vec3 attr_load_vec3(sampler3D tex); vec2 attr_load_vec2(sampler3D tex); |