载入中...
搜索中...
未找到
SkyAtmospherePass.cpp
浏览该文件的文档.
27Result<std::array<float, Shader::kMaxFloats>> viewFrame(const glm::mat4& viewProjection, const glm::vec3& eyeMetres,
44 return Result<std::array<float, Shader::kMaxFloats>>::failure(invalid("Sky camera forward must be nonzero"));
49 return Result<std::array<float, Shader::kMaxFloats>>::failure(invalid("Sky camera parameters must be finite"));
127 if (!w.densityTexture || w.corners.empty() || w.corners.size() % 27 || w.corners.size() > 9000000 ||
131 *std::min_element(w.sunDiskColor.begin(), w.sunDiskColor.end()) < 0 || w.sunDiskShape[0] <= 0 ||
133 w.materialContrast[1] <= 0 || w.materialContrast[2] < 0 || w.domeScale <= 0 || w.domeScale > 100000 ||
134 w.morphPeriod < .0001f || w.morphAmount < 0 || w.opacity < 0 || w.opacity > 1 || w.litIntensity < 0)
139 if (!w.starsTexture || !w.starsNoiseTexture || w.starsTexture->dimension != ShaderImageDimension::Image2D ||
141 return Prepared::failure(invalid("Daylight layer requires two-dimensional star and noise textures"));
143 if (w.daylight.moonDiskColor[3] > 0 && (!w.daylightEnabled || !w.moonColorTexture || !w.moonNormalTexture ||
146 return Prepared::failure(invalid("Lunar disk requires daylight and both two-dimensional textures"));
175 if (state.lifetime.expired()) return Prepared::failure(invalid("Graphics provider has retired"));
187 const float height = detail::OpticalMinimum + (detail::OpticalMaximum - detail::OpticalMinimum) *
199 if (!state.shader) return Prepared::failure(invalid("Graphics did not create an atmosphere shader"));
237 constants.insert(constants.end(), {optical ? float(detail::OpticalLayers) : 1.f, detail::OpticalMinimum,
256 auto multiBytes = std::make_shared<const std::vector<float>>(std::move(tables.multiScattering));
263 auto uploaded = graphics.replaceMeshShaderResources(*state.shader, sky_atmosphere_vert, sky_atmosphere_frag,
266 auto surface = graphics.configureMeshShaderSurface(*state.shader, BlendMode::Opaque, false, true);
275 if (!state.mesh) return Prepared::failure(invalid("Graphics did not create atmosphere geometry"));
280 auto viewUpload = graphics.replaceMeshShaderResources(*state.viewShader, sky_view_lut_vert, sky_view_lut_frag,
283 auto viewSurface = graphics.configureMeshShaderSurface(*state.viewShader, BlendMode::Opaque, false, true);
318 for (const auto& key : w.sunDiskCurve) cloudConstants.insert(cloudConstants.end(), key.begin(), key.end());
319 for (const auto* v : {&w.daylight.sun, &w.daylight.moon, &w.daylight.moonOrbit, &w.daylight.dayTint,
325 for (const auto* v : {&w.daylight.moonDiskColor, &w.daylight.moonDiskShape, &w.daylight.moonDiskLighting,
362 auto cloudSurface = graphics.configureMeshShaderSurface(*state.wispsShader, BlendMode::Opaque, false, true);
390 return Prepared::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "sky.atmosphere"));
399 if (impl_->lifetime.expired()) return Result<void>::failure(invalid("Sky graphics provider retired"));
400 if (!std::isfinite(frame.wispsMorphPhase) || frame.wispsMorphPhase < 0 || frame.wispsMorphPhase >= 1)
408 return Result<void>::failure(invalid("Sky light direction and energy must be finite; energy nonnegative"));
419Result<void> SkyAtmospherePass::prepareView(const glm::mat4& viewProjection, const glm::vec3& eyeMetres) {
420 if (impl_->lifetime.expired()) return Result<void>::failure(invalid("Sky graphics provider retired"));
431 impl_->graphics->drawMeshShader(impl_->mesh, glm::mat4(1), nullptr, Color(1, 1, 1, 1), impl_->viewShader);
439 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "sky.view"));
443Result<void> SkyAtmospherePass::draw(const glm::mat4& viewProjection, const glm::vec3& eyeMetres) {
446Result<void> SkyAtmospherePass::drawView(const glm::mat4& viewProjection, const glm::vec3& eyeMetres, bool reflection) {
448 return Result<void>::failure(Diagnostic::error(DiagnosticCode::StaleHandle, "Sky graphics provider retired"));
454 return Result<void>::failure(invalid("Sky view must be prepared before its destination pass opens"));
457 impl_->graphics->drawMeshShader(impl_->mesh, glm::mat4(1), impl_->viewCanvas->getTexture(), Color(1, 1, 1, 1),
466 std::bit_cast<float>(std::bit_cast<uint32_t>(impl_->wispsMorphPhase) | (reflection ? 0x80000000u : 0u));
468 impl_->graphics->drawMeshShader(impl_->wispsMesh, glm::mat4(1), impl_->viewCanvas->getTexture(),
472 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "sky.atmosphere"));
478 if (impl_->lifetime.expired()) return Result<void>::failure(invalid("Sky graphics provider retired"));
480 auto render = [this](Graphics& graphics, const Camera3D::Data& camera, const glm::mat4& vp, float) {
483 if (!result) std::fprintf(stderr, "SkyAtmospherePass: %s\n", result.status().describe().c_str());
486 auto preparation = addViewPreparation([this](Graphics& graphics, const glm::mat4& vp, const glm::vec3& eye) {
495 [this](Graphics& graphics, const Camera3D::Data& camera, const glm::mat4& vp, float, uint32_t) {
498 if (!result) std::fprintf(stderr, "SkyAtmospherePass: %s\n", result.status().describe().c_str());
507 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, error.what(), "sky.atmosphere"));
const std::vector< uint32_t > sky_atmosphere_frag
Definition SkyAtmosphereSpv.h:647
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
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Definition Graphics.h:125
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
std::weak_ptr< const void > resourceLifetime() const
Observe this provider's resource lifetime without extending it.
Definition GraphicsLifetime.cpp:27
virtual Result< void > replaceMeshShaderResources(Shader &shader, const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv, const ShaderResourceInputs &resources)
Replace a mesh program and its immutable set-1 resources atomically.
Definition ShaderResources.cpp:10
virtual eve::Result< void > configureMeshShaderRaster(Shader &shader, const MeshShaderRasterState &state)
Transactionally configure an owned ordinary mesh shader's raster state.
Definition Graphics.h:1847
virtual eve::Result< void > configureMeshShaderSurface(Shader &, BlendMode, bool, bool)
Prepare a custom mesh shader's blend, depth and culling state.
Definition Graphics.h:1830
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
static void removeForwardExtraDrawer(uint64_t token)
Unregister a main forward-pass contributor.
Definition RenderSystem3D.cpp:503
static void removeCaptureExtraDrawer(uint64_t token)
Unregister an offscreen capture contributor.
Definition RenderSystem3D.cpp:488
static uint64_t addCaptureExtraDrawer(uint32_t reflectionCaptureMask, CaptureExtraDrawer drawer)
Register custom forward geometry for offscreen captures.
Definition RenderSystem3D.cpp:481
static uint64_t addForwardExtraDrawer(ForwardExtraDrawer drawer)
Register a main forward-pass contributor.
Definition RenderSystem3D.cpp:496
Prepared HDR atmospheric sky draw with independent optical parameters and lookup tables.
Definition SkyAtmospherePass.h:86
Result< void > prepareView(const glm::mat4 &viewProjection, const glm::vec3 &eyeMetres)
Prepare the cached sky-view texture before opening a destination pass.
Definition SkyAtmospherePass.cpp:419
Result< void > setLight(const SkyCelestialLight &light)
Atomically set explicit light direction and RGB irradiance; rejects nonfinite or negative energy.
Definition SkyAtmospherePass.cpp:395
Result< void > setFrame(const SkyAtmosphereFrame &frame)
Validate and atomically publish solar lighting, normalized cloud phase and solar-day fraction....
Definition SkyAtmospherePass.cpp:398
static Result< std::unique_ptr< SkyAtmospherePass > > prepare(Graphics &graphics, const SkyAtmosphereParameters ¶meters, const SkyWispsLayer *wisps=nullptr)
Prepare an independent atmospheric program and immutable coefficient buffer.
Definition SkyAtmospherePass.cpp:110
Result< void > draw(const glm::mat4 &viewProjection, const glm::vec3 &eyeMetres)
Draw a prepared view into an already-open HDR 3D pass; sky writes only far-depth background pixels.
Definition SkyAtmospherePass.cpp:443
void detach() noexcept
Cancel both registrations; does not mutate legacy DayNight state.
Definition SkyAtmospherePass.cpp:510
Result< void > attach()
Register the prepared pass for main view and reflection captures, idempotently.
Definition SkyAtmospherePass.cpp:477
~SkyAtmospherePass()
Definition SkyAtmospherePass.cpp:74
std::vector< double > forward(const Policy &p, const Observation &o)
Forward.
Definition Learning.h:65
EVENGINE_API_BACKENDS Result< SkyAtmosphereLuts > bakeSkyAtmosphereLuts(const SkyAtmosphereParameters ¶meters)
Bake coefficients using UE's default 10/15-sample, two-direction approximation.
Definition SkyAtmosphereLuts.cpp:135
SkyAtmosphereParameters opticalSample(SkyAtmosphereParameters p, const SkyDaylightLayer &d, float sunY)
Pure clear/manual optical projection. Inputs are validated authored values and sun Y in [-1,...
Definition SkyOpticalCycle.h:7
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
@ RGBA32Float
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
void removeViewPreparation(uint64_t token) noexcept
Remove a registration; missing/zero tokens are harmless. @thread Graphics thread outside dispatch....
Definition ViewPreparation.cpp:31
Result< uint64_t > addViewPreparation(ViewPreparation callback)
Register a preparer for main and offscreen views; empty callbacks fail. @ownership Registry owns the ...
Definition ViewPreparation.cpp:19
@ LessEqual
@ InvalidArgument
@ Unsupported
@ Failed
@ StaleHandle
@ Opaque
Definition Container.h:602
Value snapshot of custom mesh rasterization state, independent of blending/culling.
Definition MeshShaderRasterState.h:13
MeshDepthCompare depthCompare
Definition MeshShaderRasterState.h:14
One atomic render snapshot, independent of view count or wall-clock time.
Definition SkyAtmospherePass.h:65
float dayPhase
Injected solar-day fraction in [0,1); zero is midnight, independent of render count.
Definition SkyAtmospherePass.h:69
float wispsMorphPhase
Definition SkyAtmospherePass.h:67
Spherical atmospheric coefficients in inverse kilometres and kilometre heights.
Definition SkyAtmospherePass.h:39
std::array< float, 3 > moonForward
Definition SkyAtmospherePass.cpp:61
Canvas * viewCanvas
Definition SkyAtmospherePass.cpp:68
std::weak_ptr< const void > lifetime
Definition SkyAtmospherePass.cpp:56
Mesh * wispsMesh
Definition SkyAtmospherePass.cpp:60
Shader * viewShader
Definition SkyAtmospherePass.cpp:67
std::array< float, Shader::kMaxFloats > preparedFrame
Definition SkyAtmospherePass.cpp:69
uint64_t preparation
Definition SkyAtmospherePass.cpp:66
Shader * wispsShader
Definition SkyAtmospherePass.cpp:59
Graphics * graphics
Definition SkyAtmospherePass.cpp:55
SkyCelestialLight light
Definition SkyAtmospherePass.cpp:65
float wispsMorphPhase
Definition SkyAtmospherePass.cpp:62
bool daylightEnabled
Definition SkyAtmospherePass.cpp:64
Explicit celestial lighting snapshot; unit direction points towards the light.
Definition SkyAtmospherePass.h:59
Immutable clear-sky daylight material controls, copied during sky preparation.
Definition SkyWispsLayer.h:14
Borrowed authored thin-cloud layer, consumed synchronously by sky preparation.
Definition SkyWispsLayer.h:53
bool opticalCycleEnabled
Opt-in source optical cycle, prepared as an immutable height-sampled LUT volume.
Definition SkyWispsLayer.h:57
bool daylightEnabled
Opt-in daylight chain. Disabled for legacy manifests; no independent time source.
Definition SkyWispsLayer.h:55