Fix T84095: Eevee vextex color isn't working with hair

Regression introduced by {c766d9b9dc56}. When converting the vertex
buffer to a texture buffer the fetch mode wasn't checked and the short
was bitwise interpreted as a float. This change checks the fetch_mode
and select the correct texture buffer.

This could also be added to other places when needed. At this time it is
only added here to support vertex colors when used with hair particles.
This commit is contained in:
Jeroen Bakker 2021-01-04 15:05:37 +01:00
parent c716b9862a
commit c6e5b3f42d
Notes: blender-bot 2023-02-14 10:04:50 +01:00
Referenced by issue #84095, Regression : Eevee vextex color isn't working with hair
1 changed files with 12 additions and 1 deletions

View File

@ -540,7 +540,18 @@ static inline eGPUTextureFormat to_texture_format(const GPUVertFormat *format)
case GPU_COMP_I16:
return GPU_RGBA16I;
case GPU_COMP_U16:
return GPU_RGBA16UI;
/* Note: Checking the fetch mode to select the right GPU texture format. This can be
* added to other formats as well. */
switch (format->attrs[0].fetch_mode) {
case GPU_FETCH_INT:
return GPU_RGBA16UI;
case GPU_FETCH_INT_TO_FLOAT_UNIT:
return GPU_RGBA16;
case GPU_FETCH_INT_TO_FLOAT:
return GPU_RGBA16F;
case GPU_FETCH_FLOAT:
return GPU_RGBA16F;
}
case GPU_COMP_I32:
return GPU_RGBA32I;
case GPU_COMP_U32: