Implementation of the design task #142969. This adds the following: - Exact GPU interpolation of curves of all types. - Radius attribute support. - Cyclic curve support. - Resolution attribute support. - New Cylinder hair shape type.  What changed: - EEVEE doesn't compute random normals for strand hairs anymore. These are considered legacy now. - EEVEE now have an internal shadow bias to avoid self shadowing on hair. - Workbench Curves Strip display option is no longer flat and has better shading. - Legacy Hair particle system evaluates radius at control points before applying additional subdivision. This now matches Cycles. - Color Attribute Node without a name do not fetch the active color attribute anymore. This now matches Cycles. Notes: - This is not 100% matching the CPU implementation for interpolation (see the epsilons in the tests). - Legacy Hair Particle points is now stored in local space after interpolation. The new cylinder shape allows for more correct hair shading in workbench and better intersection in EEVEE. | | Strand | Strip | Cylinder | | ---- | --- | --- | --- | | Main |  |  | N/A | | PR |  |  |  | | | Strand | Strip | Cylinder | | ---- | --- | --- | --- | | Main |  | | N/A | | PR | ||  | Cyclic Curve, Mixed curve type, and proper radius support:  Test file for attribute lookup: [test_attribute_lookup.blend](/attachments/1d54dd06-379b-4480-a1c5-96adc1953f77) Follow Up Tasks: - Correct full tube segments orientation based on tangent and normal attributes - Correct V resolution property per object - More attribute type support (currently only color) TODO: - [x] Attribute Loading Changes - [x] Generic Attributes - [x] Length Attribute - [x] Intercept Attribute - [x] Original Coordinate Attribute - [x] Cyclic Curves - [x] Legacy Hair Particle conversion - [x] Attribute Loading - [x] Additional Subdivision - [x] Move some function to generic headers (VertBuf, OffsetIndices) - [x] Fix default UV/Color attribute assignment Pull Request: https://projects.blender.org/blender/blender/pulls/143180
104 lines
1.7 KiB
C++
104 lines
1.7 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#ifndef GPU_SHADER
|
|
# include "GPU_shader_shared_utils.hh"
|
|
#endif
|
|
|
|
/* Copy of DNA enum in `DNA_curves_types.h`. */
|
|
enum CurveType : uint32_t {
|
|
CURVE_TYPE_CATMULL_ROM = 0u,
|
|
CURVE_TYPE_POLY = 1u,
|
|
CURVE_TYPE_BEZIER = 2u,
|
|
CURVE_TYPE_NURBS = 3u,
|
|
};
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
/** \name Generic Attribute
|
|
*
|
|
* These types are necessary to overcome the issue with float3 alignment on GPU.
|
|
* Having all types using the same interface allows the usage of templates to load and manipulate
|
|
* them inside the shaders.
|
|
* \{ */
|
|
|
|
struct StoredFloat4 {
|
|
float x;
|
|
float y;
|
|
float z;
|
|
float w;
|
|
};
|
|
|
|
struct StoredFloat3 {
|
|
float x;
|
|
float y;
|
|
float z;
|
|
};
|
|
|
|
struct StoredFloat2 {
|
|
float x;
|
|
float y;
|
|
};
|
|
|
|
struct StoredFloat {
|
|
float x;
|
|
};
|
|
|
|
float4 load_data(StoredFloat4 data)
|
|
{
|
|
return float4(data.x, data.y, data.z, data.w);
|
|
}
|
|
|
|
float3 load_data(StoredFloat3 data)
|
|
{
|
|
return float3(data.x, data.y, data.z);
|
|
}
|
|
|
|
float2 load_data(StoredFloat2 data)
|
|
{
|
|
return float2(data.x, data.y);
|
|
}
|
|
|
|
float load_data(StoredFloat data)
|
|
{
|
|
return float(data.x);
|
|
}
|
|
|
|
StoredFloat4 as_data(float4 interp)
|
|
{
|
|
StoredFloat4 data;
|
|
data.x = interp.x;
|
|
data.y = interp.y;
|
|
data.z = interp.z;
|
|
data.w = interp.w;
|
|
return data;
|
|
}
|
|
|
|
StoredFloat3 as_data(float3 interp)
|
|
{
|
|
StoredFloat3 data;
|
|
data.x = interp.x;
|
|
data.y = interp.y;
|
|
data.z = interp.z;
|
|
return data;
|
|
}
|
|
|
|
StoredFloat2 as_data(float2 interp)
|
|
{
|
|
StoredFloat2 data;
|
|
data.x = interp.x;
|
|
data.y = interp.y;
|
|
return data;
|
|
}
|
|
|
|
StoredFloat as_data(float interp)
|
|
{
|
|
StoredFloat data;
|
|
data.x = interp;
|
|
return data;
|
|
}
|
|
|
|
/** \} */
|