Volumetric light + fog. 更多...
#include <Volumetric.h>
Public 成员函数 | |
| Volumetric (Graphics *gfx) | |
| ~Volumetric () | |
| Volumetric (const Volumetric &)=delete | |
| Volumetric & | operator= (const Volumetric &)=delete |
| void | setQuality (const std::string &quality) |
| "low" | "medium" | "high" (unknown → medium). | |
| std::string | getQuality () const |
| void | setMode (const std::string &mode) |
| "screenspace" | "raymarch" | "fog" — selects which shader params quality tweaks. | |
| std::string | getMode () const |
| void | setLightScreenUV (float u, float v) |
| Light position in UV (0..1), origin top-left to match 2D UVs. | |
| float | getLightScreenU () const |
| float | getLightScreenV () const |
| void | setLightScreenPos (float x, float y, float width, float height) |
| Pixel-space helper (converts with width/height). | |
| void | setLightDirection (float dx, float dy, float dz) |
| World-space direction toward the lit surface (ray march / phase). | |
| void | setCamera (float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ, float fovYDeg, float aspect, float nearZ, float farZ) |
| Camera for ray march reconstruction (RH + ZO). Builds inv(viewProj) and near/far used by rayMarch*. | |
| void | setInvViewProj (const glm::mat4 &invViewProj) |
| Raw inverse view-projection (column-major, matching glm). | |
| void | setShaftColor (float r, float g, float b) |
| void | setFogColor (float r, float g, float b) |
| void | setIntensity (float intensity) |
| void | setTime (float seconds) |
| void | setDensity (float density) |
| void | setFogHeight (float worldY) |
| Height fog: denser near world Y = fogHeight; falloff is 1/meters scale. | |
| void | setFogHeightFalloff (float falloff) |
| void | setFogStart (float startDistance) |
| View-distance ramp where fog appears (world units along the ray). | |
| void | setFogEnd (float endDistance) |
| void | setFogNoise (float amount) |
| bool | hasParam (const std::string &name) const |
| void | setFloat (const std::string &name, float value) |
| float | getFloat (const std::string &name) const |
| int | getSampleCount () const |
| float | getDownscale () const |
| void | beginOcclusionMap (Graphics *gfx, float lightPixelX, float lightPixelY, float lightRadiusPixels=24.f) |
| Clear the current canvas to black and draw a bright light disc (start of an occlusion map). Call drawOcclusion* afterward. | |
| void | drawOccluder (Graphics *gfx, Drawable *drawable, const glm::mat4 &matrix) |
| Drawable occlusion (respects Drawable::getCastOcclusion). | |
| void | drawOccluderSolid (Graphics *gfx, float x, float y, float w, float h) |
| Convenience 2D black silhouette (solid or textured alpha). | |
| void | drawOccluderTexture (Graphics *gfx, Texture *texture, float x, float y, float w, float h) |
| void | scatter (Graphics *gfx, Texture *occlusion) |
| Scatter-only: occlusion → shafts with alpha (draw over a prior scene). Writes to the currently bound canvas / screen. | |
| void | scatterTo (Graphics *gfx, Texture *occlusion, Canvas *dest) |
| Same as scatter but into an explicit destination. | |
| void | applyFromScene (Graphics *gfx, Texture *scene) |
| Single-pass: treat source as the scene (bright regions ≈ light), add shafts + dust/fog onto it. Writes to current canvas. | |
| void | applyFromSceneTo (Graphics *gfx, Texture *scene, Canvas *dest) |
| void | rayMarch (Graphics *gfx, Texture *linearDepth) |
| Ray march participating media using a linear-depth texture (R channel, 0=near .. 1=far). Screen-space steps toward light UV approximate CSM occlusion. Call setCamera / setLightDirection / setLightScreenUV first. | |
| void | rayMarchTo (Graphics *gfx, Texture *linearDepth, Canvas *dest) |
| void | applyFog (Graphics *gfx, Texture *linearDepth) |
| Volumetric height/distance fog from a linear-depth texture. Writes fog RGB with alpha = 1-transmittance (overlay with alpha blend). Call setCamera / setFogHeight* / setFogStart/End first. | |
| void | applyFogTo (Graphics *gfx, Texture *linearDepth, Canvas *dest) |
| Texture * | newLinearDepthTexture (Graphics *gfx, int width, int height, float(*depth01)(int x, int y, void *userdata), void *userdata) |
| Build an RGBA8 texture with linear depth in R (G=B=R, A=255). depth01(x,y) should return values in [0,1]. Owned by Graphics. | |
| int | resolutionFor (int fullSize) const |
| Downscale helper: returns floor(dim / downscale), at least 1. Callers create occlusion / scatter canvases at this size for the active quality tier. | |
| void | drawOccluders2D (Graphics *gfx) |
| Draw all visible Renderable2D with castOcclusion into the current canvas as black silhouettes (shadow-analogue occlusion pass). | |
| Shader * | getShader () const |
| Shader * | getRayMarchShader () const |
| Shader * | getFogShader () const |
详细描述
Volumetric light + fog.
Modes:
- "screenspace" — Mitchell radial blur god rays (+ dust/fog tint)
- "raymarch" — depth ray march light shafts (SS occlusion ≈ CSM)
- "fog" — height + distance volumetric fog (Beer-Lambert)
Quality presets ("low" | "medium" | "high") control sample count and suggested downscale via resolutionFor().
在文件 Volumetric.h 第 27 行定义.
构造及析构函数说明
◆ Volumetric() [1/2]
|
explicit |
在文件 Volumetric.cpp 第 163 行定义.
◆ ~Volumetric()
|
default |
◆ Volumetric() [2/2]
|
delete |
成员函数说明
◆ applyFog()
Volumetric height/distance fog from a linear-depth texture. Writes fog RGB with alpha = 1-transmittance (overlay with alpha blend). Call setCamera / setFogHeight* / setFogStart/End first.
在文件 Volumetric.cpp 第 522 行定义.
被这些函数引用 applyFogTo().
◆ applyFogTo()
在文件 Volumetric.cpp 第 527 行定义.
引用了 applyFog(), eve::graphics::Graphics::getCanvas() , 以及 eve::graphics::Graphics::setCanvas().
◆ applyFromScene()
Single-pass: treat source as the scene (bright regions ≈ light), add shafts + dust/fog onto it. Writes to current canvas.
在文件 Volumetric.cpp 第 494 行定义.
被这些函数引用 applyFromSceneTo().
◆ applyFromSceneTo()
◆ beginOcclusionMap()
| void eve::graphics::Volumetric::beginOcclusionMap | ( | Graphics * | gfx, |
| float | lightPixelX, | ||
| float | lightPixelY, | ||
| float | lightRadiusPixels = 24.f |
||
| ) |
Clear the current canvas to black and draw a bright light disc (start of an occlusion map). Call drawOcclusion* afterward.
在文件 Volumetric.cpp 第 436 行定义.
引用了 eve::graphics::Canvas::clear(), eve::graphics::Graphics::drawSolidRect(), eve::graphics::Graphics::getCanvas(), eve::graphics::Graphics::getHeight(), eve::graphics::Canvas::getHeight(), eve::graphics::Graphics::getWidth(), eve::graphics::Canvas::getWidth(), h, setLightScreenPos() , 以及 w.
◆ drawOccluder()
| void eve::graphics::Volumetric::drawOccluder | ( | Graphics * | gfx, |
| Drawable * | drawable, | ||
| const glm::mat4 & | matrix | ||
| ) |
Drawable occlusion (respects Drawable::getCastOcclusion).
在文件 Volumetric.cpp 第 448 行定义.
◆ drawOccluders2D()
| void eve::graphics::Volumetric::drawOccluders2D | ( | Graphics * | gfx | ) |
Draw all visible Renderable2D with castOcclusion into the current canvas as black silhouettes (shadow-analogue occlusion pass).
在文件 Volumetric.cpp 第 464 行定义.
引用了 eve::graphics::Graphics::drawOcclusionSolid(), eve::graphics::Graphics::drawOcclusionTexture(), h, view , 以及 w.
◆ drawOccluderSolid()
| void eve::graphics::Volumetric::drawOccluderSolid | ( | Graphics * | gfx, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h | ||
| ) |
Convenience 2D black silhouette (solid or textured alpha).
在文件 Volumetric.cpp 第 453 行定义.
引用了 eve::graphics::Graphics::drawOcclusionSolid(), h, w, x , 以及 y.
◆ drawOccluderTexture()
| void eve::graphics::Volumetric::drawOccluderTexture | ( | Graphics * | gfx, |
| Texture * | texture, | ||
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h | ||
| ) |
在文件 Volumetric.cpp 第 458 行定义.
引用了 eve::graphics::Graphics::drawOcclusionTexture(), h, w, x , 以及 y.
◆ getDownscale()
|
inline |
在文件 Volumetric.h 第 84 行定义.
◆ getFloat()
| float eve::graphics::Volumetric::getFloat | ( | const std::string & | name | ) | const |
在文件 Volumetric.cpp 第 365 行定义.
引用了 eve::graphics::Shader::getFromVar(), eve::graphics::Shader::hasUniform(), name , 以及 v.
被这些函数引用 getLightScreenU(), getLightScreenV() , 以及 getSampleCount().
◆ getFogShader()
|
inline |
在文件 Volumetric.h 第 154 行定义.
◆ getLightScreenU()
| float eve::graphics::Volumetric::getLightScreenU | ( | ) | const |
在文件 Volumetric.cpp 第 250 行定义.
引用了 getFloat().
◆ getLightScreenV()
| float eve::graphics::Volumetric::getLightScreenV | ( | ) | const |
在文件 Volumetric.cpp 第 251 行定义.
引用了 getFloat().
◆ getMode()
|
inline |
在文件 Volumetric.h 第 41 行定义.
◆ getQuality()
|
inline |
在文件 Volumetric.h 第 37 行定义.
◆ getRayMarchShader()
|
inline |
在文件 Volumetric.h 第 153 行定义.
◆ getSampleCount()
| int eve::graphics::Volumetric::getSampleCount | ( | ) | const |
在文件 Volumetric.cpp 第 390 行定义.
引用了 getFloat().
◆ getShader()
|
inline |
在文件 Volumetric.h 第 152 行定义.
◆ hasParam()
| bool eve::graphics::Volumetric::hasParam | ( | const std::string & | name | ) | const |
在文件 Volumetric.cpp 第 353 行定义.
引用了 eve::graphics::Shader::hasUniform() , 以及 name.
◆ newLinearDepthTexture()
| Texture * eve::graphics::Volumetric::newLinearDepthTexture | ( | Graphics * | gfx, |
| int | width, | ||
| int | height, | ||
| float(*)(int x, int y, void *userdata) | depth01, | ||
| void * | userdata | ||
| ) |
Build an RGBA8 texture with linear depth in R (G=B=R, A=255). depth01(x,y) should return values in [0,1]. Owned by Graphics.
在文件 Volumetric.cpp 第 536 行定义.
引用了 b, d, height, eve::graphics::Graphics::newTexture(), width, x , 以及 y.
◆ operator=()
|
delete |
◆ rayMarch()
Ray march participating media using a linear-depth texture (R channel, 0=near .. 1=far). Screen-space steps toward light UV approximate CSM occlusion. Call setCamera / setLightDirection / setLightScreenUV first.
在文件 Volumetric.cpp 第 508 行定义.
被这些函数引用 rayMarchTo().
◆ rayMarchTo()
在文件 Volumetric.cpp 第 513 行定义.
引用了 eve::graphics::Graphics::getCanvas(), rayMarch() , 以及 eve::graphics::Graphics::setCanvas().
◆ resolutionFor()
| int eve::graphics::Volumetric::resolutionFor | ( | int | fullSize | ) | const |
Downscale helper: returns floor(dim / downscale), at least 1. Callers create occlusion / scatter canvases at this size for the active quality tier.
在文件 Volumetric.cpp 第 392 行定义.
◆ scatter()
Scatter-only: occlusion → shafts with alpha (draw over a prior scene). Writes to the currently bound canvas / screen.
在文件 Volumetric.cpp 第 480 行定义.
被这些函数引用 scatterTo().
◆ scatterTo()
Same as scatter but into an explicit destination.
在文件 Volumetric.cpp 第 485 行定义.
引用了 eve::graphics::Graphics::getCanvas(), scatter() , 以及 eve::graphics::Graphics::setCanvas().
◆ setCamera()
| void eve::graphics::Volumetric::setCamera | ( | float | eyeX, |
| float | eyeY, | ||
| float | eyeZ, | ||
| float | targetX, | ||
| float | targetY, | ||
| float | targetZ, | ||
| float | upX, | ||
| float | upY, | ||
| float | upZ, | ||
| float | fovYDeg, | ||
| float | aspect, | ||
| float | nearZ, | ||
| float | farZ | ||
| ) |
Camera for ray march reconstruction (RH + ZO). Builds inv(viewProj) and near/far used by rayMarch*.
在文件 Volumetric.cpp 第 278 行定义.
引用了 fovRad, eve::graphics::perspectiveVulkanRH_ZO(), proj, eve::graphics::Shader::sendFloat(), setInvViewProj() , 以及 view.
◆ setDensity()
| void eve::graphics::Volumetric::setDensity | ( | float | density | ) |
在文件 Volumetric.cpp 第 322 行定义.
引用了 eve::graphics::Shader::sendFloat() , 以及 setFloat().
◆ setFloat()
| void eve::graphics::Volumetric::setFloat | ( | const std::string & | name, |
| float | value | ||
| ) |
在文件 Volumetric.cpp 第 358 行定义.
引用了 eve::graphics::Shader::hasUniform(), name, eve::graphics::Shader::sendFloat() , 以及 value.
被这些函数引用 setDensity(), setFogColor(), setIntensity(), setLightScreenUV(), setShaftColor() , 以及 setTime().
◆ setFogColor()
| void eve::graphics::Volumetric::setFogColor | ( | float | r, |
| float | g, | ||
| float | b | ||
| ) |
在文件 Volumetric.cpp 第 305 行定义.
引用了 b, eve::graphics::Shader::sendFloat() , 以及 setFloat().
◆ setFogEnd()
| void eve::graphics::Volumetric::setFogEnd | ( | float | endDistance | ) |
在文件 Volumetric.cpp 第 343 行定义.
◆ setFogHeight()
| void eve::graphics::Volumetric::setFogHeight | ( | float | worldY | ) |
Height fog: denser near world Y = fogHeight; falloff is 1/meters scale.
在文件 Volumetric.cpp 第 328 行定义.
◆ setFogHeightFalloff()
| void eve::graphics::Volumetric::setFogHeightFalloff | ( | float | falloff | ) |
在文件 Volumetric.cpp 第 333 行定义.
◆ setFogNoise()
| void eve::graphics::Volumetric::setFogNoise | ( | float | amount | ) |
在文件 Volumetric.cpp 第 348 行定义.
◆ setFogStart()
| void eve::graphics::Volumetric::setFogStart | ( | float | startDistance | ) |
View-distance ramp where fog appears (world units along the ray).
在文件 Volumetric.cpp 第 338 行定义.
◆ setIntensity()
| void eve::graphics::Volumetric::setIntensity | ( | float | intensity | ) |
在文件 Volumetric.cpp 第 314 行定义.
引用了 eve::graphics::Shader::sendFloat() , 以及 setFloat().
◆ setInvViewProj()
| void eve::graphics::Volumetric::setInvViewProj | ( | const glm::mat4 & | invViewProj | ) |
Raw inverse view-projection (column-major, matching glm).
在文件 Volumetric.cpp 第 272 行定义.
引用了 eve::graphics::Shader::sendMatrix().
被这些函数引用 setCamera().
◆ setLightDirection()
| void eve::graphics::Volumetric::setLightDirection | ( | float | dx, |
| float | dy, | ||
| float | dz | ||
| ) |
World-space direction toward the lit surface (ray march / phase).
在文件 Volumetric.cpp 第 259 行定义.
引用了 d , 以及 eve::graphics::Shader::sendFloat().
◆ setLightScreenPos()
| void eve::graphics::Volumetric::setLightScreenPos | ( | float | x, |
| float | y, | ||
| float | width, | ||
| float | height | ||
| ) |
Pixel-space helper (converts with width/height).
在文件 Volumetric.cpp 第 253 行定义.
引用了 height, setLightScreenUV(), width, x , 以及 y.
被这些函数引用 beginOcclusionMap().
◆ setLightScreenUV()
| void eve::graphics::Volumetric::setLightScreenUV | ( | float | u, |
| float | v | ||
| ) |
Light position in UV (0..1), origin top-left to match 2D UVs.
在文件 Volumetric.cpp 第 243 行定义.
引用了 eve::graphics::Shader::sendFloat(), setFloat(), u , 以及 v.
被这些函数引用 setLightScreenPos().
◆ setMode()
| void eve::graphics::Volumetric::setMode | ( | const std::string & | mode | ) |
"screenspace" | "raymarch" | "fog" — selects which shader params quality tweaks.
在文件 Volumetric.cpp 第 233 行定义.
◆ setQuality()
| void eve::graphics::Volumetric::setQuality | ( | const std::string & | quality | ) |
"low" | "medium" | "high" (unknown → medium).
在文件 Volumetric.cpp 第 228 行定义.
◆ setShaftColor()
| void eve::graphics::Volumetric::setShaftColor | ( | float | r, |
| float | g, | ||
| float | b | ||
| ) |
在文件 Volumetric.cpp 第 296 行定义.
引用了 b, eve::graphics::Shader::sendFloat() , 以及 setFloat().
◆ setTime()
| void eve::graphics::Volumetric::setTime | ( | float | seconds | ) |
在文件 Volumetric.cpp 第 320 行定义.
引用了 setFloat().
该类的文档由以下文件生成:
- src/modules/graphics/Volumetric.h
- src/modules/graphics/Volumetric.cpp