t3ssel8r-style stylized grass. 更多...
类 | |
| struct | BillboardMesh |
| struct | PackedAtlasInfo |
| Layout of a packed 2x2-per-variant sway atlas (4 grass + 2 leaf typical). 更多... | |
| struct | Point |
| struct | SampleParams |
函数 | |
| int | paramCount () |
| std::string | paramName (int index) |
| void | bindDefaults (Shader *shader) |
| void | bindAtlasLayout (Shader *shader, const PackedAtlasInfo &info) |
| void | bindLayer (Shader *shader, bool alwaysDark) |
| void | setTime (Shader *shader, float seconds) |
| void | setFrameDuration (Shader *shader, float seconds) |
| Shader * | createShader (Graphics *gfx) |
| int | swayFrame (float time, float frameDuration, uint32_t instanceId, int frameCount=4) |
| Discrete 4-frame index with a per-instance phase offset. | |
| int | swayAtlasWidth (int frameW, int frames) |
| int | swayAtlasHeight (int frameH) |
| void | makeSwayAtlasRGBA (int frameW, int frameH, int frames, std::vector< uint8_t > &rgbaOut) |
| Procedural 4-frame fallback atlas (horizontal strip). GPU paths should load authored 2x2 PNG masks via packSwayAtlasRGBA / createSwayAtlasFromFiles. | |
| Texture * | createSwayAtlas (Graphics *gfx, int frameW, int frameH, int frames) |
| void | packSwayAtlasRGBA (const std::vector< std::string > &grassFiles, const std::vector< std::string > &leafFiles, std::vector< uint8_t > &rgbaOut, PackedAtlasInfo &info) |
| Load white-on-black (or RGBA) 2x2 sway PNGs and pack them into one atlas. | |
| Texture * | createSwayAtlasFromFiles (Graphics *gfx, const std::vector< std::string > &grassFiles, const std::vector< std::string > &leafFiles, PackedAtlasInfo *infoOut) |
| std::vector< Point > | sampleHalton (const float *posXYZ, const float *nrmXYZ, int vertexCount, const uint32_t *indices, int indexCount, int count, uint32_t seed=1, float minSlopeDot=0.25f) |
| Area-weighted Halton samples (deterministic, evenly spread). | |
| std::vector< Point > | samplePoisson (const float *posXYZ, const float *nrmXYZ, int vertexCount, const uint32_t *indices, int indexCount, const SampleParams ¶ms={}) |
| Fast Poisson-disk / dart-throwing blue noise on a triangle mesh. | |
| BillboardMesh | buildBillboards (const std::vector< Point > &points, float width=0.62f, float height=0.95f, bool alwaysDark=false) |
| Expand a unit rectangle per point. Vertex layout: pos = grass root uv = quad corner in [0,1]^2 (0.5, 0) is the root normal.x = instance id, normal.y = scale, normal.z = alwaysDark (0/1) | |
| void | makePlane (float sizeX, float sizeZ, int segX, int segZ, std::vector< float > &posXYZ, std::vector< float > &nrmXYZ, std::vector< uint32_t > &indices) |
| Unit XZ plane (Y-up) for tests / demos. | |
详细描述
t3ssel8r-style stylized grass.
Pipeline:
- Blue-noise (Poisson disk) or Halton samples on a terrain mesh
- Expand a root-pivoted rectangle into a GPU mesh (one quad per sample)
- Vertex shader cylindrical-billboards each card around its root
- 4-frame sway atlas, phase-offset by instance id
- Shadow map → mix(light green, dark green)
- Sparse second pass, always dark, as decoration
函数说明
◆ bindAtlasLayout()
| void eve::graphics::grass::bindAtlasLayout | ( | Shader * | shader, |
| const PackedAtlasInfo & | info | ||
| ) |
引用了 eve::graphics::grass::PackedAtlasInfo::atlasCols, eve::graphics::grass::PackedAtlasInfo::atlasRows, eve::graphics::grass::PackedAtlasInfo::frames, eve::graphics::grass::PackedAtlasInfo::grassVariants, eve::graphics::grass::PackedAtlasInfo::leafRowOffset, eve::graphics::grass::PackedAtlasInfo::leafVariants , 以及 shader.
被这些函数引用 eve::graphics::GrassField::bake().
◆ bindDefaults()
| void eve::graphics::grass::bindDefaults | ( | Shader * | shader | ) |
◆ bindLayer()
| void eve::graphics::grass::bindLayer | ( | Shader * | shader, |
| bool | alwaysDark | ||
| ) |
◆ buildBillboards()
| BillboardMesh eve::graphics::grass::buildBillboards | ( | const std::vector< Point > & | points, |
| float | width, | ||
| float | height, | ||
| bool | alwaysDark | ||
| ) |
Expand a unit rectangle per point. Vertex layout: pos = grass root uv = quad corner in [0,1]^2 (0.5, 0) is the root normal.x = instance id, normal.y = scale, normal.z = alwaysDark (0/1)
引用了 c, height, mesh, n, p, points, eve::graphics::grass::BillboardMesh::posXYZ , 以及 width.
被这些函数引用 eve::graphics::GrassField::bake().
◆ createShader()
◆ createSwayAtlas()
◆ createSwayAtlasFromFiles()
| Texture * eve::graphics::grass::createSwayAtlasFromFiles | ( | Graphics * | gfx, |
| const std::vector< std::string > & | grassFiles, | ||
| const std::vector< std::string > & | leafFiles, | ||
| PackedAtlasInfo * | infoOut | ||
| ) |
◆ makePlane()
| void eve::graphics::grass::makePlane | ( | float | sizeX, |
| float | sizeZ, | ||
| int | segX, | ||
| int | segZ, | ||
| std::vector< float > & | posXYZ, | ||
| std::vector< float > & | nrmXYZ, | ||
| std::vector< uint32_t > & | indices | ||
| ) |
◆ makeSwayAtlasRGBA()
| void eve::graphics::grass::makeSwayAtlasRGBA | ( | int | frameW, |
| int | frameH, | ||
| int | frames, | ||
| std::vector< uint8_t > & | rgbaOut | ||
| ) |
Procedural 4-frame fallback atlas (horizontal strip). GPU paths should load authored 2x2 PNG masks via packSwayAtlasRGBA / createSwayAtlasFromFiles.
引用了 f, h, swayAtlasHeight(), swayAtlasWidth() , 以及 w.
被这些函数引用 createSwayAtlas().
◆ packSwayAtlasRGBA()
| void eve::graphics::grass::packSwayAtlasRGBA | ( | const std::vector< std::string > & | grassFiles, |
| const std::vector< std::string > & | leafFiles, | ||
| std::vector< uint8_t > & | rgbaOut, | ||
| PackedAtlasInfo & | info | ||
| ) |
Load white-on-black (or RGBA) 2x2 sway PNGs and pack them into one atlas.
引用了 eve::graphics::grass::PackedAtlasInfo::atlasCols, eve::graphics::grass::PackedAtlasInfo::atlasRows, eve::graphics::grass::PackedAtlasInfo::frames, eve::graphics::grass::PackedAtlasInfo::grassVariants, h, eve::graphics::grass::PackedAtlasInfo::height, kind, eve::graphics::grass::PackedAtlasInfo::leafRowOffset, eve::graphics::grass::PackedAtlasInfo::leafVariants, eve::Loaded, p, w , 以及 eve::graphics::grass::PackedAtlasInfo::width.
被这些函数引用 createSwayAtlasFromFiles().
◆ paramCount()
◆ paramName()
◆ sampleHalton()
| std::vector< Point > eve::graphics::grass::sampleHalton | ( | const float * | posXYZ, |
| const float * | nrmXYZ, | ||
| int | vertexCount, | ||
| const uint32_t * | indices, | ||
| int | indexCount, | ||
| int | count, | ||
| uint32_t | seed, | ||
| float | minSlopeDot | ||
| ) |
◆ samplePoisson()
| std::vector< Point > eve::graphics::grass::samplePoisson | ( | const float * | posXYZ, |
| const float * | nrmXYZ, | ||
| int | vertexCount, | ||
| const uint32_t * | indices, | ||
| int | indexCount, | ||
| const SampleParams & | params | ||
| ) |
Fast Poisson-disk / dart-throwing blue noise on a triangle mesh.
引用了 idx, eve::graphics::grass::SampleParams::maxPoints, eve::graphics::grass::SampleParams::minSlopeDot, n, p, pos, eve::graphics::grass::Point::position, eve::graphics::grass::SampleParams::radius, eve::graphics::grass::SampleParams::seed, u , 以及 v.
被这些函数引用 eve::graphics::GrassField::bake().
◆ setFrameDuration()
| void eve::graphics::grass::setFrameDuration | ( | Shader * | shader, |
| float | seconds | ||
| ) |
引用了 shader.
被这些函数引用 eve::graphics::GrassField::draw() , 以及 eve::graphics::GrassField::setFrameDuration().
◆ setTime()
| void eve::graphics::grass::setTime | ( | Shader * | shader, |
| float | seconds | ||
| ) |
◆ swayAtlasHeight()
| int eve::graphics::grass::swayAtlasHeight | ( | int | frameH | ) |
被这些函数引用 createSwayAtlas() , 以及 makeSwayAtlasRGBA().
◆ swayAtlasWidth()
| int eve::graphics::grass::swayAtlasWidth | ( | int | frameW, |
| int | frames | ||
| ) |
被这些函数引用 createSwayAtlas() , 以及 makeSwayAtlasRGBA().