载入中...
搜索中...
未找到
SurfaceField.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include <glm/glm.hpp>
5
6#include <vector>
7
8namespace eve::gpuagents {
9
17public:
18 glm::vec3 origin{-16.f, 0.f, -16.f};
19 float worldSize = 32.f;
20 int resolution = 64;
21
23 std::vector<float> height;
25 std::vector<glm::vec3> normals;
27 std::vector<glm::vec4> lifeField;
28
30 void initFlat(const glm::vec3& originMin, float size, int res, float planeY = 0.f);
31
33 glm::vec2 worldToUv(const glm::vec3& p) const;
34
36 float sampleHeight(float x, float z) const;
37
39 glm::vec3 sampleNormal(float x, float z) const;
40
42 glm::vec4 sampleLife(float x, float z) const;
43
45 glm::vec3 project(const glm::vec3& p) const;
46
56 void stepLife(float dt, float decayRate, float halfLife, float diffusion,
57 const std::vector<glm::vec3>& deposits, float depositStrength);
58
59private:
60 int index(int x, int z) const;
61 bool inBounds(int x, int z) const;
62 glm::vec4 sampleLifeTexel(float u, float v) const;
63};
64
65} // namespace eve::gpuagents
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
glm::vec4 p[6]
#define EVENGINE_API_DOMAINS
Definition Export.h:110
float u
Definition Grass.cpp:233
float v
V3 origin
Definition RoadBake.cpp:138
float size
Definition TreeMesh.cpp:156
uint32_t index
2.5D surface + life-field textures for Life Network.
std::vector< glm::vec4 > lifeField
Life field RGBA: R=trail, G=nutrient, B=danger, A=freshness.
std::vector< glm::vec3 > normals
Packed normals as vec3 per texel.
std::vector< float > height
Height samples, resolution^2, row-major X then Z.