载入中...
搜索中...
未找到
VegetationPresetConversion.cpp
浏览该文件的文档.
20 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, std::move(message), {}, {},
84 const float determinant = direction[0] * (direction[4] * direction[8] - direction[7] * direction[5]) -
88 return direction[a] * direction[b] + direction[a + 1] * direction[b + 1] + direction[a + 2] * direction[b + 2];
90 if (std::abs(determinant - 1.f) > 1e-4f || std::abs(dot(0, 0) - 1.f) > 1e-4f || std::abs(dot(3, 3) - 1.f) > 1e-4f ||
91 std::abs(dot(6, 6) - 1.f) > 1e-4f || std::abs(dot(0, 3)) > 1e-4f || std::abs(dot(0, 6)) > 1e-4f ||
118 if (tangent->second.components != 4 || tangent->second.values.size() / 4 != mesh.positions.size() / 3)
135 std::optional<asset::CanonicalMeshData> mesh, const std::map<std::string, VegetationPresetImage>& textures,
149 DiagnosticCode::InvalidArgument, "world conversion requires both point and direction matrices", {},
157 auto converted = executeVegetationMeshRules(result.candidate, std::move(*mesh), textures, variationSeed);
196 } else if (!mesh && !result.candidate.meshRules.empty() && result.meshOutput != VegetationMeshOutputMode::Off) {
202 auto packed = result.mesh ? executeVegetationTexturePacks(result.candidate, textures, *result.mesh)
215Result<VegetationConversionResult> executeUnityVegetationConversion(const UnityVegetationConversionRequest& request) {
223 auto source = decodeUnityVegetationConversionCandidate(request.materialYaml, request.sourcePath,
226 auto context = makeVegetationPresetContext(source.value(), request.shaderName, request.materialName,
228 auto commands = evaluateVegetationPreset(request.presetDefinitions, request.rootPreset, context);
230 return executeVegetationConversion(std::move(source).takeValue(), commands.value(), request.mesh,
263 return !value.empty() && value.size() <= 127 && std::all_of(value.begin(), value.end(), [](unsigned char c) {
269 return std::all_of(value.begin(), value.end(), [](double component) { return std::isfinite(component); });
288 Diagnostic::error(DiagnosticCode::Conflict, "material vector and color values conflict", name, {},
295 Diagnostic::error(DiagnosticCode::InvalidArgument, "invalid vegetation material float", name, {},
300 Diagnostic::error(DiagnosticCode::InvalidArgument, "invalid vegetation material vector", name, {},
322 Diagnostic::error(DiagnosticCode::InvalidArgument, "invalid vegetation texture transform", name, {},
330 for (const auto& [name, value] : candidate.materialFloats) text << " - " << name << ": " << value << '\n';
338 Diagnostic::error(DiagnosticCode::InvalidArgument, "encoded vegetation material exceeds byte budget",
343 Diagnostic::error(DiagnosticCode::Failed, "vegetation material encoding allocation failed", {}, {},
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Definition AssetImporter.h:14
EVENGINE_API_PLATFORM Result< std::vector< std::uint8_t > > encodeUnityVegetationConversionMaterial(const VegetationConversionCandidate &candidate, std::uint64_t maximumBytes=16ull *1024ull *1024ull)
Encode an applied vegetation candidate as a detached Unity text Material for the canonical TVE import...
Definition VegetationPresetConversion.cpp:279
@ TransformToWorldSpace
EVENGINE_API_PLATFORM Result< VegetationConversionCandidate > applyVegetationPreset(VegetationConversionCandidate source, const std::vector< VegetationPresetCommand > &commands)
Type-check and atomically apply an evaluated TVE command sequence.
Definition VegetationPresetApply.cpp:187
EVENGINE_API_PLATFORM Result< VegetationConversionResult > executeUnityVegetationConversion(const UnityVegetationConversionRequest &request)
Decode a Unity Material, evaluate one TVE preset graph, and execute every output atomically.
Definition VegetationPresetConversion.cpp:215
EVENGINE_API_PLATFORM Result< asset::CanonicalMeshData > executeVegetationMeshRules(const VegetationConversionCandidate &candidate, asset::CanonicalMeshData source, float variationSeed=1.f)
Execute preset mask and coordinate rules into canonical TVE authoring streams.
Definition VegetationPresetMesh.cpp:482
Result< VegetationConversionCandidate > decodeUnityVegetationConversionCandidate(std::span< const std::uint8_t > yaml, std::string sourcePath, std::uint64_t maximumBytes)
Decode Unity text Material saved properties into an owning vegetation conversion baseline.
Definition VegetationConversionImport.cpp:318
VegetationPresetContext makeVegetationPresetContext(const VegetationConversionCandidate &candidate, std::string shaderName, std::string materialName, std::string shaderPipeline, std::set< std::string > outputOptions)
Project one conversion baseline into immutable preset predicate facts.
Definition VegetationConversionImport.cpp:427
EVENGINE_API_PLATFORM Result< std::map< std::string, VegetationPresetImage > > executeVegetationTexturePacks(const VegetationConversionCandidate &candidate, const std::map< std::string, VegetationPresetImage > &sources, std::uint64_t maximumPixels=16ull *1024ull *1024ull)
Execute all texture recipes against detached RGBA8 source images.
Definition VegetationPresetTexture.cpp:205
EVENGINE_API_PLATFORM Result< VegetationConversionResult > executeVegetationConversion(VegetationConversionCandidate source, const std::vector< VegetationPresetCommand > &commands, std::optional< asset::CanonicalMeshData > mesh, const std::map< std::string, VegetationPresetImage > &textures, float variationSeed=1.f, const std::optional< std::array< float, 16 > > &sourceToWorld={}, const std::optional< std::array< float, 9 > > &sourceDirectionToWorld={})
Apply commands and execute all available mesh and texture outputs as one transaction.
Definition VegetationPresetConversion.cpp:133
Result< std::vector< VegetationPresetCommand > > evaluateVegetationPreset(const std::map< std::string, Value > &definitions, std::string_view root, const VegetationPresetContext &context)
Decode, resolve and evaluate a library of canonical TVE preset definitions.
Definition VegetationPreset.cpp:176
Status invalid(const char *message)
Definition OceanBindingInternal.h:21
@ InvalidArgument
@ NotFound
@ Unsupported
@ Failed
@ ParseError
@ Conflict
Definition Container.h:602
Owning inputs for one complete Unity Material and TVE preset conversion transaction.
Definition VegetationPreset.h:106
Owning unpublished material, mesh and texture candidate mutated transactionally by preset commands.
Definition VegetationPreset.h:63
std::string materialShader
Definition VegetationPreset.h:72
std::map< std::string, std::array< double, 4 > > materialVectors
Definition VegetationPreset.h:65
bool materialInstancing
Definition VegetationPreset.h:74
std::set< std::string > materialKeywords
Definition VegetationPreset.h:69
std::map< std::string, std::array< double, 4 > > materialColors
Definition VegetationPreset.h:66
std::map< std::string, double > materialFloats
Definition VegetationPreset.h:64
std::map< std::string, std::array< double, 4 > > materialTextureTransforms
Definition VegetationPreset.h:68
std::map< std::string, std::string > materialTextures
Definition VegetationPreset.h:67
Complete detached output of one vegetation preset conversion transaction.
Definition VegetationPreset.h:92
VegetationConversionCandidate candidate
Definition VegetationPreset.h:93