载入中...
搜索中...
未找到
eve::graphics::grass 命名空间参考

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)
 
ShadercreateShader (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.
 
TexturecreateSwayAtlas (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.
 
TexturecreateSwayAtlasFromFiles (Graphics *gfx, const std::vector< std::string > &grassFiles, const std::vector< std::string > &leafFiles, PackedAtlasInfo *infoOut)
 
std::vector< PointsampleHalton (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< PointsamplePoisson (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.
 
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:

  1. Blue-noise (Poisson disk) or Halton samples on a terrain mesh
  2. Expand a root-pivoted rectangle into a GPU mesh (one quad per sample)
  3. Vertex shader cylindrical-billboards each card around its root
  4. 4-frame sway atlas, phase-offset by instance id
  5. Shadow map → mix(light green, dark green)
  6. Sparse second pass, always dark, as decoration

函数说明

◆ bindAtlasLayout()

◆ bindDefaults()

void eve::graphics::grass::bindDefaults ( Shader shader)

在文件 Grass.cpp289 行定义.

引用了 shader.

被这些函数引用 eve::graphics::GrassField::bake() , 以及 createShader().

◆ bindLayer()

void eve::graphics::grass::bindLayer ( Shader shader,
bool  alwaysDark 
)

在文件 Grass.cpp331 行定义.

引用了 shader.

被这些函数引用 eve::graphics::GrassField::draw().

◆ 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)

在文件 Grass.cpp583 行定义.

引用了 c, height, mesh, n, p, points, eve::graphics::grass::BillboardMesh::posXYZ , 以及 width.

被这些函数引用 eve::graphics::GrassField::bake().

◆ createShader()

Shader * eve::graphics::grass::createShader ( Graphics gfx)

◆ createSwayAtlas()

Texture * eve::graphics::grass::createSwayAtlas ( Graphics gfx,
int  frameW,
int  frameH,
int  frames 
)

◆ 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 
)

Unit XZ plane (Y-up) for tests / demos.

在文件 Grass.cpp618 行定义.

引用了 i0, i1, i2, px, x , 以及 z.

被这些函数引用 eve::graphics::GrassField::bakePlane().

◆ 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.

在文件 Grass.cpp369 行定义.

引用了 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 
)

◆ paramCount()

int eve::graphics::grass::paramCount ( )

在文件 Grass.cpp282 行定义.

◆ paramName()

std::string eve::graphics::grass::paramName ( int  index)

在文件 Grass.cpp284 行定义.

◆ 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 
)

Area-weighted Halton samples (deterministic, evenly spread).

在文件 Grass.cpp518 行定义.

引用了 n, p, seed, u , 以及 v.

◆ 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 
)

◆ setFrameDuration()

void eve::graphics::grass::setFrameDuration ( Shader shader,
float  seconds 
)

在文件 Grass.cpp341 行定义.

引用了 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)

在文件 Grass.cpp367 行定义.

被这些函数引用 createSwayAtlas() , 以及 makeSwayAtlasRGBA().

◆ swayAtlasWidth()

int eve::graphics::grass::swayAtlasWidth ( int  frameW,
int  frames 
)

在文件 Grass.cpp366 行定义.

被这些函数引用 createSwayAtlas() , 以及 makeSwayAtlasRGBA().

◆ swayFrame()

int eve::graphics::grass::swayFrame ( float  time,
float  frameDuration,
uint32_t  instanceId,
int  frameCount 
)

Discrete 4-frame index with a per-instance phase offset.

在文件 Grass.cpp357 行定义.

引用了 f.