载入中...
搜索中...
未找到
FogRayMarch.cpp
浏览该文件的文档.
16[[nodiscard]] std::optional<FogRayInterval> intersectSlab(float origin, float dir, float minV, float maxV) {
27[[nodiscard]] std::optional<FogRayInterval> intersectRayAabb(const glm::vec3& o, const glm::vec3& d,
41std::optional<FogRayInterval> FogRayMarch::intersectBound(const glm::vec3& origin, const glm::vec3& direction,
84Result<FogRayResult> FogRayMarch::integrate(const FogDensityField& field, const FogProfile& profile,
93 DiagnosticCode::InvalidArgument, "sampleCount must be in [1,256]", "sampleCount", {}, "graphics.fog"));
98 DiagnosticCode::InvalidArgument, "direction must be non-zero", "direction", {}, "graphics.fog"));
169Result<void> FogSystem::configureDomain(int simWidth, int simHeight, int simDepth, const FogWorldBounds& bounds,
179Result<void> FogSystem::seedHeightFog(float baseDensity, float baseHeight, float falloff, float curlScale,
200Result<void> FogSystem::ensureBeerCache(const glm::vec3& lightDir, const glm::vec3& lightColor, float intensity) {
218 const BeerLightCache* cache = (budget.beerLightCache && beerCache_.valid()) ? &beerCache_ : nullptr;
219 return rayMarch_.integrate(density_, profile_, origin, direction, bound, lightDir, lightColor, lightIntensity,
224Result<int> FogSystem::renderToFroxel(AtmosphereVolume& volume, const glm::mat4& invViewProj, const glm::vec3& lightDir,
238 auto injected = froxelBridge_.inject(volume, density_, profile_, invViewProj, budget.occupancySkip);
241 const BeerLightCache* cache = (budget.beerLightCache && beerCache_.valid()) ? &beerCache_ : nullptr;
243 froxelBridge_.integrate(volume, density_, profile_, invViewProj, lightDir, lightColor, intensity, cache);
256 return Result<int>::failure(Diagnostic::error(DiagnosticCode::Failed, "froxel/density volumes are empty",
266 Diagnostic::error(DiagnosticCode::InvalidArgument, "volumetric is null", "volumetric", {}, "graphics.fog"));
277Result<int> FogSystem::syncToVolumetric(Volumetric* volumetric, const glm::vec3& lightDir, const glm::vec3& lightColor,
281 Diagnostic::error(DiagnosticCode::InvalidArgument, "volumetric is null", "volumetric", {}, "graphics.fog"));
299 volumetric->configureFroxelGrid(budget.froxelWidth, budget.froxelHeight, budget.froxelDepth, nearDistance,
312 auto injected = froxelBridge_.inject(*volume, density_, profile_, invViewProj, budget.occupancySkip);
315 const BeerLightCache* cache = (budget.beerLightCache && beerCache_.valid()) ? &beerCache_ : nullptr;
317 froxelBridge_.integrate(*volume, density_, profile_, invViewProj, lightDir, lightColor, intensity, cache);
325 return volLight_.integrate(beam, profile_, origin, direction, sceneDepth, budget.volLightSegments, mediumDensity);
328Result<std::vector<DustParticle>> FogSystem::generateDust(int count, float turbulenceMeters, std::uint32_t seed) const {
Stable, structured diagnostics shared by engine modules.
Structured operation status used by the common Result foundation.
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
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
Camera-frustum volume used by the volumetric fog passes and CPU references.
Definition AtmosphereVolume.h:37
const glm::mat4 & getInvViewProj() const
Inverse view-projection last written by setCamera / setInvViewProj.
Definition Volumetric.h:215
AtmosphereVolume * getAtmosphereVolume() const
Access the froxel media grid for native density/light injection.
Definition Volumetric.h:213
void configureFroxelGrid(int width, int height, int depth, float nearDistance, float farDistance)
Configure the CPU reference/fallback froxel grid used by the atlas renderer. Quality presets choose s...
Definition Volumetric.cpp:758
Result< FogRayResult > integrate(const AnalyticBeam &beam, const FogProfile &profile, const glm::vec3 &origin, const glm::vec3 &direction, float sceneDepth, int segments, float mediumDensity) const
Integrate the beam contribution along a view ray.
Definition AnalyticalVolLight.cpp:61
Cached light-path transmittance used by Fast / Enhanced quality tiers.
Definition BeerLightCache.h:20
Result< void > rebuild(const FogDensityField &field, const FogProfile &profile, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float intensity, int samplesPerCell=6)
Rebuild transmittance along the primary light for each density cell.
Definition AnalyticalVolLight.cpp:127
bool matches(std::uint64_t densityRevision, const glm::vec3 &lightDir, float intensity) const noexcept
True when the cache matches the supplied state.
Definition AnalyticalVolLight.cpp:119
void invalidate()
Mark cache stale (quality change, light cut, etc.).
Definition AnalyticalVolLight.cpp:114
float sampleTransmittance(const FogDensityField &field, const glm::vec3 &world) const noexcept
Sample cached transmittance at a world position (1 = fully lit).
Definition AnalyticalVolLight.cpp:181
World-space density bands, curl assist velocity, and lighting helpers.
Definition FogDensityField.h:21
const FogWorldBounds & bounds() const noexcept
Definition FogDensityField.h:29
Result< void > seedHeightBand(float baseDensity, float baseHeight, float falloff, float curlScale, std::uint32_t seed)
Seed a height-banded density layer with optional curl noise.
Definition FogDensityField.cpp:173
Result< void > resize(int width, int height, int depth, const FogWorldBounds &bounds)
Allocate a regular lattice over world bounds.
Definition FogDensityField.cpp:28
std::uint64_t revision() const noexcept
Definition FogDensityField.h:31
Result< void > integrate(AtmosphereVolume &volume, const FogDensityField &field, const FogProfile &profile, const glm::mat4 &invViewProj, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float intensity, const BeerLightCache *beerCache)
Integrate froxels with optional Beer-cache visibility.
Definition FogDensityField.cpp:270
Result< int > inject(AtmosphereVolume &volume, const FogDensityField &field, const FogProfile &profile, const glm::mat4 &invViewProj, bool occupancySkip)
Inject density-field media into an AtmosphereVolume froxel grid.
Definition FogDensityField.cpp:243
Unit-density optical profile for participating media.
Definition FogProfile.h:16
float extinctionAt(float density) const noexcept
Extinction for a sampled density value.
Definition FogDensityField.cpp:540
glm::vec3 ambientRadiance(const glm::vec3 &skyUp, const glm::vec3 &groundDown, float density) const noexcept
Ambient term using up/down visibility and AO.
Definition FogDensityField.cpp:551
float phase(float cosTheta) const noexcept
Dual-lobe Henyey–Greenstein phase evaluated for cosθ.
Definition FogDensityField.cpp:544
glm::vec3 scatteringAt(float density) const noexcept
Scattering coefficient σ_s = albedo * σ_t.
Definition FogDensityField.cpp:542
static std::optional< FogRayInterval > intersectBound(const glm::vec3 &origin, const glm::vec3 &direction, const FogVolumeBound &bound)
Intersect a ray with a volume bound; returns empty when misses.
Definition FogRayMarch.cpp:41
Result< FogRayResult > integrate(const FogDensityField &field, const FogProfile &profile, const glm::vec3 &origin, const glm::vec3 &direction, const FogVolumeBound &bound, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float lightIntensity, const glm::vec3 &skyAmbient, const glm::vec3 &groundAmbient, int sampleCount, float sceneDepth, const BeerLightCache *beerCache, bool useAnalyticSegments) const
Integrate one view ray through the density field.
Definition FogRayMarch.cpp:84
Result< int > injectToFroxel(AtmosphereVolume &volume, const glm::mat4 &invViewProj)
Add MAC density into an existing froxel grid without clearing or integrating.
Definition FogRayMarch.cpp:254
Result< std::vector< DustParticle > > generateDust(int count, float turbulenceMeters, std::uint32_t seed=7u) const
Generate procedural dust for the simulation bounds.
Definition FogRayMarch.cpp:328
Result< void > setQuality(FogQuality quality)
Select Fast / Enhanced / PhysicalReference and invalidate caches.
Definition FogRayMarch.cpp:163
Result< FogRayResult > integrateBeam(const AnalyticBeam &beam, const glm::vec3 &origin, const glm::vec3 &direction, float sceneDepth, float mediumDensity) const
Analytic beam integration using the active quality segment count.
Definition FogRayMarch.cpp:322
Result< FogRayResult > marchRay(const glm::vec3 &origin, const glm::vec3 &direction, const FogVolumeBound &bound, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float lightIntensity, const glm::vec3 &skyAmbient, const glm::vec3 &groundAmbient, float sceneDepth) const
World-space ray march through the live density field.
Definition FogRayMarch.cpp:213
Result< int > renderToFroxel(AtmosphereVolume &volume, const glm::mat4 &invViewProj, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float intensity)
Inject + integrate the density field into a froxel AtmosphereVolume.
Definition FogRayMarch.cpp:224
Result< int > syncToVolumetric(Volumetric *volumetric, const glm::vec3 &lightDir, const glm::vec3 &lightColor, float intensity)
Map the live density field into a Volumetric froxel grid and integrate lighting. Resizes the atlas to...
Definition FogRayMarch.cpp:277
ContinuousArtOutput stylize(const FogRayResult &physical, float viewZ, float neighborOpacity=0.f) const noexcept
Apply ContinuousArt to a physical ray result.
Definition FogRayMarch.cpp:332
Result< int > injectToVolumetric(Volumetric *volumetric)
Additive MAC inject into a Volumetric that already holds height fog / volumes. Does not resize,...
Definition FogRayMarch.cpp:263
Result< void > configureDomain(int simWidth, int simHeight, int simDepth, const FogWorldBounds &bounds, float fixedDt=1.f/60.f)
Allocate density + MAC over world bounds at the quality froxel-ish resolution. Simulation resolution ...
Definition FogRayMarch.cpp:169
Result< void > seedHeightFog(float baseDensity, float baseHeight, float falloff, float curlScale, std::uint32_t seed=1u)
Seed a height-banded fog volume.
Definition FogRayMarch.cpp:179
Result< FogCflReport > stepSimulation(float dt)
Advance wind + MAC fluid by wall-clock dt (fixed substeps inside).
Definition FogRayMarch.cpp:189
Result< void > ensureBeerCache(const glm::vec3 &lightDir, const glm::vec3 &lightColor, float intensity)
Refresh BeerLightCache when quality/light/density require it.
Definition FogRayMarch.cpp:200
Result< void > configure(const FogDensityField &field, float fixedDt=kDefaultFixedDt)
Allocate MAC arrays matching a density field lattice.
Definition MacFluidGrid.cpp:14
Result< void > pullDensity(const FogDensityField &field)
Copy concentration from a density field (same resolution).
Definition MacFluidGrid.cpp:63
Result< void > pushDensity(FogDensityField &field) const
Write concentration back into a density field.
Definition MacFluidGrid.cpp:74
Result< FogCflReport > step(float dt, SceneWind &wind, FogInteractor *interactor, float simTime)
Advance simulation by wall-clock dt using fixed substeps.
Definition MacFluidGrid.cpp:372
Result< std::vector< DustParticle > > generate(const FogWorldBounds &volume, int count, float timeSeconds, float turbulenceMeters, std::uint32_t seed) const
Generate dust inside an AABB for the current view time.
Definition ProceduralDust.cpp:27
Definition AnalyticalVolLight.cpp:10
FogQualityBudget budgetFor(FogQuality quality) noexcept
Resolve the budget for a quality preset.
Definition FogTypes.h:52
@ PhysicalReference
Dense tracking, no skip shortcuts.
@ InvalidArgument
@ Failed
@ NoOp
Analytic beam volume: capped cone frustum or pyramidal spot.
Definition AnalyticalVolLight.h:16
Stylized fog presentation derived from a physical FogRayResult.
Definition FogTypes.h:169
Interval along a ray where media is present (t in world units).
Definition FogTypes.h:112
Optical result of integrating one view ray through fog.
Definition FogTypes.h:122
Analytic volume used to bound a camera ray before sampling.
Definition FogRayMarch.h:17
glm::vec3 obbHalfExtents
Definition FogRayMarch.h:26
Axis-aligned world bounds for a fog simulation domain.
Definition FogTypes.h:96