载入中...
搜索中...
未找到
VegetationMaskPacking.cpp
浏览该文件的文档.
2#include <cmath>
3#include <new>
5namespace eve::graphics {
6Result<VegetationMask> packVegetationOrm(const VegetationMask& source, float occlusion, float smoothness) {
7 auto unit = [](float v) { return std::isfinite(v) && v >= 0.f && v <= 1.f; };
8 const uint64_t pixelCount = uint64_t(source.width) * source.height;
9 if (!unit(occlusion) || !unit(smoothness) || !source.width || !source.height || pixelCount > 16ull * 1024 * 1024 ||
10 source.pixels.size() != pixelCount)
12 "invalid vegetation mask dimensions or factors", {},
13 {}, "graphics.vegetation.mask"));
14 for (const auto& pixel : source.pixels)
15 for (unsigned c = 0; c < 4; ++c)
16 if (!unit(pixel[c]))
18 DiagnosticCode::InvalidArgument, "vegetation source mask must contain finite linear unit values",
19 {}, {}, "graphics.vegetation.mask"));
20 try {
21 VegetationMask result;
22 result.width = source.width;
23 result.height = source.height;
24 result.pixels.reserve(source.pixels.size());
25 for (const auto& pixel : source.pixels)
26 result.pixels.emplace_back(std::lerp(1.f, pixel.g, occlusion), 1.f - pixel.a * smoothness, 0.f, pixel.b);
27 return Result<VegetationMask>::success(std::move(result));
28 } catch (const std::bad_alloc&) {
30 DiagnosticCode::Failed, "vegetation mask allocation failed", {}, {}, "graphics.vegetation.mask"));
31 }
32}
33} // namespace eve::graphics
float v
std::int32_t c
TacticalUnit * unit
const UnitySourceAsset & source
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Result< VegetationMask > packVegetationOrm(const VegetationMask &source, float occlusion, float smoothness)
Project a TVE main/detail linear mask into the native PBR ORM channel convention. Source G is occlusi...
Owning linear RGBA mask, sampled bilinearly with clamped addressing.
std::vector< glm::vec4 > pixels