载入中...
搜索中...
未找到
HairCards.cpp
浏览该文件的文档.
20void pushVertex(CardMeshData &mesh, float x, float y, float z, float nx, float ny, float nz, float u, float v) {
31void pushQuad(CardMeshData &mesh, float ax, float ay, float az, float bx, float by, float bz, float cx, float cy,
59void cross3(float ax, float ay, float az, float bx, float by, float bz, float &ox, float &oy, float &oz) {
93 pushQuad(mesh, a[0] - sx * hw, a[1] - sy * hw, a[2] - sz * hw, a[0] + sx * hw, a[1] + sy * hw, a[2] + sz * hw,
127 return gfx->newMeshFromArrays(data.positions.data(), data.normals.data(), data.uvs.data(), vertexCount,
131Mesh *newCardMesh(Graphics *gfx, float width, float height) { return uploadCardMesh(gfx, buildCard(width, height)); }
155void configureCardLod(Renderable3D *renderable, Mesh *nearCards, Mesh *farProxy, float switchDistance) {
176std::vector<uint32_t> copySpv(const uint32_t *data, size_t count) { return std::vector<uint32_t>(data, data + count); }
222 Shader *sh = gfx->getBackendName() == "webgpu" ? gfx->newHairShaderFromWgsl({}, shaders::kHairFragWgsl)
224 if (!sh || !sh->gpuHandle) throw eve::Exception("hair::createShader: failed to create hair shader");
Definition Graphics.h:134
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
virtual Shader * newHairShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create an alpha-blended hair/card shader from WGSL on WebGPU.
virtual Shader * newHairShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Hair/fur card shader (alpha blend + Kajiya-Kay). Empty vert → mesh3d_hair.vert. Owned by Graphics.
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:38
void setBlendMode(const std::string &mode)
Set "alpha", "premultiplied", "additive", or "multiply".
Definition Material.cpp:183
void setSurfaceMode(const std::string &mode)
Set "opaque", "masked", or "transparent" surface classification.
Definition Material.cpp:166
void setShadingModel(const std::string &model)
"pbr" | "unlit" | "hair" | "custom" (unknown → pbr).
Definition Material.cpp:106
void setMeshLod(int index, Mesh *mesh, float switchDistance=0.f)
Configure geometric LOD. index 0 = highest detail. For index > 0, switchDistance is the camera distan...
Definition Renderable3D.cpp:195
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
void cross3(float ax, float ay, float az, float bx, float by, float bz, float &x, float &y, float &z)
Definition PlacementGeometry.cpp:210
Procedural hair/fur card meshes + material/LOD helpers (no strand simulation).
Definition Graphics.h:64
int paramCount()
Push-constant parameter names (same order as mesh3d_hair.frag).
Definition HairCards.cpp:180
CardMeshData buildCardsAlongPolyline(const float *pointsXYZ, int pointCount, float width)
Build one card per polyline segment, facing a camera-facing side approximated by world up.
Definition HairCards.cpp:76
CardMeshData buildCard(float width, float height)
Build a single upright card in local space (origin at root, height along +Y, face +Z).
Definition HairCards.cpp:67
CardMeshData buildCardsFromRoots(const CardRoot *roots, int rootCount)
Expand root samples into independent cards.
Definition HairCards.cpp:100
Mesh * newCardMesh(Graphics *gfx, float width, float height)
Convenience: single card mesh.
Definition HairCards.cpp:131
void applyCardDefaults(Material &mat)
Apply transparent hair-card surface defaults (double-sided, no depth write/shadows)....
Definition HairCards.cpp:133
Material * makeCardMaterial(Graphics *gfx, Texture *albedo, Shader *hairShader)
Create a Material configured for hair cards and optionally bind the hair shader + albedo.
Definition HairCards.cpp:145
Mesh * uploadCardMesh(Graphics *gfx, const CardMeshData &data)
Upload card arrays as a Graphics-owned Mesh.
Definition HairCards.cpp:123
void configureCardLod(Renderable3D *renderable, Mesh *nearCards, Mesh *farProxy, float switchDistance)
Wire near/far geometric LOD on a renderable (index 0 = cards, index 1 = proxy).
Definition HairCards.cpp:155
void appendCardMesh(CardMeshData &dst, const CardMeshData &src)
Append src into dst (vertex/index rebase).
Definition HairCards.cpp:115
Shader * createShader(Graphics *gfx)
Create the default hair shader (alpha-blended, anisotropic specular). Owned by Graphics.
Definition HairCards.cpp:218
void bindDefaults(Shader *shader)
Bind default push-constant knobs on an existing hair shader.
Definition HairCards.cpp:187
constexpr const char * kHairFragWgsl
Hair fragment shader WGSL source. @ownership Borrowed immutable string literal; callers must not free...
Definition HairWgsl.h:8
CPU-side interleaved mesh arrays for upload via Graphics::newMeshFromArrays.
Definition HairCards.h:27