diff options
Diffstat (limited to 'source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl index 3c5acf62e30..ea9d98c5060 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_attributes_lib.glsl @@ -112,6 +112,7 @@ float attr_load_float(float attr) /** \name Curve * * Curve objects loads attributes from buffers through sampler buffers. + * Per attribute scope follows loading order. * \{ */ # ifdef OBINFO_LIB @@ -122,6 +123,22 @@ vec3 attr_load_orco(vec4 orco) return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz; } # endif + +int g_curves_attr_id = 0; + +/* Return the index to use for looking up the attribute value in the sampler + * based on the attribute scope (point or spline). */ +int curves_attribute_element_id() +{ + int id = interp.curves_strand_id; + if (drw_curves.is_point_attribute[g_curves_attr_id] != 0) { + id = hair_get_base_id(); + } + + g_curves_attr_id += 1; + return id; +} + vec4 attr_load_tangent(samplerBuffer cd_buf) { /* Not supported for the moment. */ @@ -137,19 +154,19 @@ vec4 attr_load_color(samplerBuffer cd_buf) } vec4 attr_load_vec4(samplerBuffer cd_buf) { - return texelFetch(cd_buf, interp.curves_strand_id).rgba; + return texelFetch(cd_buf, curves_attribute_element_id()).rgba; } vec3 attr_load_vec3(samplerBuffer cd_buf) { - return texelFetch(cd_buf, interp.curves_strand_id).rgb; + return texelFetch(cd_buf, curves_attribute_element_id()).rgb; } vec2 attr_load_vec2(samplerBuffer cd_buf) { - return texelFetch(cd_buf, interp.curves_strand_id).rg; + return texelFetch(cd_buf, curves_attribute_element_id()).rg; } float attr_load_float(samplerBuffer cd_buf) { - return texelFetch(cd_buf, interp.curves_strand_id).r; + return texelFetch(cd_buf, curves_attribute_element_id()).r; } /** \} */ |