载入中...
搜索中...
未找到
EvpackVegetationScene.h
浏览该文件的文档.
1#pragma once
2
9
10#include <array>
11#include <map>
12#include <glm/vec2.hpp>
13#include <memory>
14#include <vector>
15#include <span>
16
17namespace eve::asset_graphics {
18
28
31 float windPower = .5f, noiseTiling = 1, bending = 1, branch = 1, flutter = 1;
32 float speed = 1, fadeDistance = 100;
33 bool animatedTime = true;
34 std::array<float, 2> direction{-1, 0};
35 std::string noiseTextureGuid;
36};
37
40 std::int32_t renderMode = 10;
41 std::uint32_t width = 1024, height = 1024;
42};
43
46 float renderScale = 1, edgeFade = .75f;
47 std::uint32_t visibility = 0, sorting = 0;
48 std::array<VegetationSceneVolumeChannel, 4> channels{};
49};
50
54 std::int32_t type = 0;
55 std::array<float, 4> vector{};
56 float value = 0;
57};
58
61 std::int64_t sourceFileId = 0;
63 std::vector<VegetationSceneElementProperty> properties;
64 std::uint32_t channel = 0;
65 bool enabled = true, seasonal = false, invertDirection = false, volumeFade = false;
66 std::int32_t visibility = -1, blendRgb = 0, blendAlpha = 0, directionMode = 20, motionMode = 15;
67 std::uint16_t layers = 1;
68 float intensity = 1, motionPower = 0;
69 std::array<float, 3> position{}, scale{1, 1, 1};
70 std::array<float, 4> rotation{0, 0, 0, 1}, value{1, 1, 1, 1};
71 std::array<std::array<float, 4>, 4> seasons{};
72 std::array<float, 6> remap{0, 1, 0, 1, 0, 0};
73};
74
77 glm::vec2 localUv{.5f};
78 glm::vec4 mainSample{1.f};
79 glm::vec4 elementParams{1.f};
80 glm::vec4 vertexColor{1.f};
81 glm::vec3 worldPosition{0.f};
82 glm::vec3 worldNormal{0.f, 1.f, 0.f};
83 glm::vec2 velocityDirection{0.f};
84 glm::vec4 noiseSample{0.f};
85 float terrainHeight = 0.f;
86 float volumeFade = 1.f;
87 float season = 2.f;
88};
89
91enum class VegetationScenePixelBlend : std::uint8_t { Alpha, Multiply, Add, Replace };
92
101
113
121
124public:
126 explicit EvpackVegetationSceneLoader(const asset::EvpackResourceReader& reader) noexcept : reader_(reader) {}
127
133 [[nodiscard]] Result<LoadedVegetationScene> load(const AssetRef& asset,
134 const asset::EvpackCapabilities& capabilities,
135 std::uint64_t maximumDecodedBytes = 1024 * 1024) const;
136
137private:
138 const asset::EvpackResourceReader& reader_;
139};
140
150 const graphics::PbrSurface& baseSurface, const graphics::VegetationMotion& baseMotion,
151 const LoadedVegetationScene& scene);
152
164loadVegetationSceneElementMasks(const asset::EvpackResourceReader& reader, const LoadedVegetationScene& scene,
165 const asset::EvpackCapabilities& capabilities,
166 std::uint64_t maximumDecodedBytes = 256 * 1024 * 1024);
167
176 const VegetationSceneElement& element, const VegetationSceneElementPixelInput& input);
177
180 glm::vec4 destination, const VegetationSceneElementPixel& source) noexcept;
181
195 const LoadedVegetationScene& scene, const std::map<std::string, graphics::VegetationMask>& masks,
196 const graphics::VegetationAtlas& base, std::array<std::uint8_t, 4> layers = {},
197 std::span<const glm::vec3> worldNormals = {}, std::span<const float> terrainHeights = {},
198 std::span<const glm::vec4> noiseSamples = {});
199
205[[nodiscard]] Result<graphics::VegetationChannelAtlas> bakeVegetationSceneChannel(
206 const LoadedVegetationScene& scene, const std::map<std::string, graphics::VegetationMask>& masks,
207 graphics::VegetationChannel channel, const graphics::VegetationChannelAtlas& base, std::uint8_t layer = 0,
208 std::span<const glm::vec3> worldNormals = {}, std::span<const float> terrainHeights = {},
209 std::span<const glm::vec4> noiseSamples = {});
210
217[[nodiscard]] EVENGINE_API_WORLD Result<graphics::VegetationAtlas> convertVegetationSceneAtlasToNative(
218 const graphics::VegetationAtlas& tveAtlas);
219
221[[nodiscard]] Result<graphics::VegetationChannelAtlas> convertVegetationSceneChannelToNative(
222 graphics::VegetationChannel channel, const graphics::VegetationChannelAtlas& tveAtlas);
223
226 std::array<graphics::VegetationChannelAtlas, 9> baseLayers;
227 std::span<const glm::vec3> worldNormals{};
228 std::span<const float> terrainHeights{};
229 std::span<const glm::vec4> noiseSamples{};
230};
231
234 std::array<VegetationSceneChannelGpuBuild, 4> channels;
236 std::uint64_t sourceRevision = 0;
237};
238
241 std::uint64_t revision = 0;
242 std::size_t deferredReleaseCount = 0;
243};
244
251public:
263 [[nodiscard]] static Result<std::unique_ptr<VegetationSceneGpuRuntime>> create(
264 graphics::IResourceFactory& factory, const graphics::PbrSurface& baseSurface,
266 const std::map<std::string, graphics::VegetationMask>& masks, const VegetationSceneGpuBuild& build);
267
272
274 [[nodiscard]] const graphics::PbrSurface& surface() const noexcept { return projection_.surface; }
276 [[nodiscard]] const graphics::VegetationMotion& motion() const noexcept { return projection_.motion; }
278 [[nodiscard]] std::uint64_t sourceRevision() const noexcept { return sourceRevision_; }
280 [[nodiscard]] std::size_t deferredReleaseCount() const noexcept { return retiredFields_.size(); }
289 [[nodiscard]] Result<VegetationSceneGpuPublication> replace(
290 std::uint64_t expectedRevision, const graphics::PbrSurface& baseSurface,
292 const std::map<std::string, graphics::VegetationMask>& masks, const VegetationSceneGpuBuild& build);
294 [[nodiscard]] Result<void> release();
295
296private:
297 explicit VegetationSceneGpuRuntime(graphics::IResourceFactory& factory) noexcept : factory_(&factory) {}
298
299 graphics::IResourceFactory* factory_ = nullptr;
301 std::vector<graphics::VegetationGpuFieldSet> retiredFields_;
302 VegetationSceneProjection projection_;
303 std::uint64_t sourceRevision_ = 0;
304};
305
306} // namespace eve::asset_graphics
Typed capability-aware runtime access to admitted packs.
EvpackChunkInput input
Definition Evpack.cpp:170
#define EVENGINE_API_WORLD
Definition Export.h:109
TileLayer * layer
std::weak_ptr< PrimitiveScene > scene
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
std::string element
const UnitySourceAsset & source
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Immutable reader retaining an admitted pack by shared ownership.
Strict capability-aware decoder for eve.vegetation-scene/1.
EvpackVegetationSceneLoader(const asset::EvpackResourceReader &reader) noexcept
Bind a borrowed immutable reader which must outlive this loader.
Owning GPU publication of one immutable TVE manager scene. The resource factory, mask map and scene a...
const graphics::VegetationMotion & motion() const noexcept
Borrow the projected CPU motion snapshot; valid for this runtime's lifetime.
std::uint64_t sourceRevision() const noexcept
Revision shared by the immutable scene input and every GPU field texture.
std::size_t deferredReleaseCount() const noexcept
Number of superseded field sets retained because their factory release must be retried.
const graphics::PbrSurface & surface() const noexcept
Borrow the bound material snapshot; valid until release begins or destruction.
VegetationSceneGpuRuntime & operator=(const VegetationSceneGpuRuntime &)=delete
VegetationSceneGpuRuntime(const VegetationSceneGpuRuntime &)=delete
Texture / mesh / shader / canvas creation and release.
Result< graphics::VegetationChannelAtlas > convertVegetationSceneChannelToNative(graphics::VegetationChannel channel, const graphics::VegetationChannelAtlas &tveAtlas)
Convert one fully composed TVE channel atlas to EVEngine conventions.
Result< graphics::VegetationChannelAtlas > bakeVegetationSceneChannel(const LoadedVegetationScene &scene, const std::map< std::string, graphics::VegetationMask > &masks, graphics::VegetationChannel channel, const graphics::VegetationChannelAtlas &base, std::uint8_t layer, std::span< const glm::vec3 > worldNormals, std::span< const float > terrainHeights, std::span< const glm::vec4 > noiseSamples)
Bake one TVE manager channel at its own resolution and world mapping.
Result< VegetationSceneElementPixel > evaluateVegetationSceneElementPixel(const VegetationSceneElement &element, const VegetationSceneElementPixelInput &input)
Evaluate one TVE Element fragment using caller-supplied texture, instance and particle inputs.
Result< VegetationSceneProjection > projectVegetationScene(const graphics::PbrSurface &baseSurface, const graphics::VegetationMotion &baseMotion, const LoadedVegetationScene &scene)
Project validated TVE manager controls onto one material/motion snapshot.
Result< graphics::VegetationAtlas > convertVegetationSceneAtlasToNative(const graphics::VegetationAtlas &tveAtlas)
Convert a fully composed TVE render-target atlas to EVEngine field channel conventions.
VegetationScenePixelBlend
Detached TVE render-target source value and independent hardware blend policy.
Result< graphics::VegetationAtlas > bakeVegetationSceneElements(const LoadedVegetationScene &scene, const std::map< std::string, graphics::VegetationMask > &masks, const graphics::VegetationAtlas &base, std::array< std::uint8_t, 4 > layers, std::span< const glm::vec3 > worldNormals, std::span< const float > terrainHeights, std::span< const glm::vec4 > noiseSamples)
Rasterize the ordered TVE Element list over an owning four-channel atlas candidate.
Result< std::map< std::string, graphics::VegetationMask > > loadVegetationSceneElementMasks(const asset::EvpackResourceReader &reader, const LoadedVegetationScene &scene, const asset::EvpackCapabilities &capabilities, std::uint64_t maximumDecodedBytes)
Decode every runtime texture used by admitted TVE Element shaders into owning linear masks.
glm::vec4 composeVegetationSceneElementPixel(glm::vec4 destination, const VegetationSceneElementPixel &source) noexcept
Apply one evaluated source pixel to a destination with TVE's separate blend factors and ColorMask.
VegetationChannel
Independent vegetation field channels; values use linear color and world units.
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
Result of ordered capability variant selection.
Definition Evpack.h:155
Fully validated, detached scene-manager candidate with no archive or GPU borrows.
graphics::VegetationDetailSettings details
std::vector< VegetationSceneElement > elements
Detached inputs for one independently sized TVE manager channel.
std::array< graphics::VegetationChannelAtlas, 9 > baseLayers
Owning TVE Global Control values; texture identities remain source-map GUIDs.
Explicit per-draw inputs consumed by one TVE Element fragment evaluation.
Detached TVE render-target source value and independent hardware blend policy.
One normalized Unity TVEElement definition awaiting texture realization.
One normalized Unity TVEElement definition awaiting texture realization.
std::vector< VegetationSceneElementProperty > properties
std::array< std::array< float, 4 >, 4 > seasons
Explicit detached inputs for publishing all nine TVE scene-manager field layers.
std::array< VegetationSceneChannelGpuBuild, 4 > channels
Receipt for one atomic scene-manager GPU replacement.
Owning TVE Global Motion values; time is supplied by each frame.
Detached PBR and CPU-motion snapshot ready for atomic material publication.
One TVE volume texture channel allocation policy.
Owning TVE Global Volume policy; render resources are allocated by the runtime host.
std::array< VegetationSceneVolumeChannel, 4 > channels
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:218
Four owning arrays in row-major X/Z order at texel centers.
TVE Global Details values, independent of scene components and global shader state.
Coherent detached projections for all four vegetation channels. Textures are factory-owned....
Runtime-owned global inputs shared by one coherent vegetation field binding. Time is explicit for det...
Source-equivalent plant motion parameters with explicit time and texture inputs. All data is owned....