feat: add direction particle advection
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -80,6 +80,7 @@ struct ParticleSettings {
|
||||
float particleOpacity;
|
||||
float trailOpacity;
|
||||
float trailFade;
|
||||
float advectionScale;
|
||||
bool speedColorEnabled;
|
||||
std::array<float, 4> particleColor;
|
||||
std::array<float, 4> trailColor;
|
||||
@@ -99,11 +100,12 @@ ParticleSettings particleSettings(const Immutable<style::Layer::Impl>& value) {
|
||||
layer.particleOpacity,
|
||||
layer.trailOpacity,
|
||||
layer.trailFade,
|
||||
layer.advectionScale,
|
||||
layer.speedColorEnabled, layer.particleColor, layer.trailColor};
|
||||
}
|
||||
assert(value->getTypeInfo() == style::ParticleValidationLayer::Impl::staticTypeInfo());
|
||||
const auto& layer = static_cast<const style::ParticleValidationLayer::Impl&>(*value);
|
||||
return {layer.active, layer.maskMode, layer.fixtureMode, false, 0.0f, 256, 2.0f, 0.018f, 1.0f, 1.0f, 0.965f, false,
|
||||
return {layer.active, layer.maskMode, layer.fixtureMode, false, 0.0f, 256, 2.0f, 0.018f, 1.0f, 1.0f, 0.965f, 1.0f, false,
|
||||
{0.08f, 0.55f, 1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
|
||||
}
|
||||
|
||||
@@ -342,6 +344,7 @@ public:
|
||||
float particleOpacity = 1.0f;
|
||||
float trailOpacity = 1.0f;
|
||||
float trailFade = 0.92f;
|
||||
float advectionScale = 1.0f;
|
||||
bool speedColorEnabled = true;
|
||||
std::array<float, 4> particleColor{0.08f, 0.55f, 1.0f, 1.0f};
|
||||
std::array<float, 4> trailColor{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
@@ -580,6 +583,10 @@ public:
|
||||
resources->nextFieldScale,
|
||||
resources->viewportDensityActive ? 1.0f : 0.0f,
|
||||
0.0f},
|
||||
.advection = {resources->field.vectorSemantics == particle::VectorSemantics::Direction ? 1.0f : 0.0f,
|
||||
resources->advectionScale,
|
||||
0.00001f,
|
||||
0.0f},
|
||||
.particleColor = resources->particleColor,
|
||||
.trailColor = resources->trailColor,
|
||||
.weatherStops = {},
|
||||
@@ -915,6 +922,7 @@ RenderRasterParticleLayer::RenderRasterParticleLayer(Immutable<style::Layer::Imp
|
||||
settings.particleOpacity,
|
||||
settings.trailOpacity,
|
||||
settings.trailFade,
|
||||
settings.advectionScale,
|
||||
settings.speedColorEnabled,
|
||||
settings.particleColor,
|
||||
settings.trailColor);
|
||||
@@ -954,6 +962,7 @@ void RenderRasterParticleLayer::evaluate(const PropertyEvaluationParameters&) {
|
||||
settings.particleOpacity,
|
||||
settings.trailOpacity,
|
||||
settings.trailFade,
|
||||
settings.advectionScale,
|
||||
settings.speedColorEnabled,
|
||||
settings.particleColor,
|
||||
settings.trailColor);
|
||||
@@ -970,6 +979,7 @@ void RenderRasterParticleLayer::evaluate(const PropertyEvaluationParameters&) {
|
||||
std::to_string(settings.lineWidth) + " streakLength=" + std::to_string(settings.particleLength) +
|
||||
" particleOpacity=" + std::to_string(settings.particleOpacity) + " trailOpacity=" +
|
||||
std::to_string(settings.trailOpacity) + " trailFade=" + std::to_string(settings.trailFade) +
|
||||
" advectionScale=" + std::to_string(settings.advectionScale) +
|
||||
" speedColor=" + (settings.speedColorEnabled ? "true" : "false") + " stage=40-05");
|
||||
}
|
||||
|
||||
@@ -1077,12 +1087,11 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Particle advection consumes only physical U/V velocity. Scalar-only
|
||||
// fields and direction vectors are unavailable until V3-04 defines their
|
||||
// separate advection contract.
|
||||
// Particle advection requires a compatible vector pair. Scalar-only
|
||||
// remains unavailable; VELOCITY and DIRECTION are resolved in the shader.
|
||||
if (formalSource && (!sourceField->hasVector() || !sourceNextField->hasVector() ||
|
||||
sourceField->vectorSemantics != particle::VectorSemantics::Velocity ||
|
||||
sourceNextField->vectorSemantics != particle::VectorSemantics::Velocity)) {
|
||||
!sourceField->vectorSemantics || !sourceNextField->vectorSemantics ||
|
||||
sourceField->vectorSemantics != sourceNextField->vectorSemantics)) {
|
||||
if (layerGroup) static_cast<LayerGroup&>(*layerGroup).clearDrawables();
|
||||
if (gpuResources) {
|
||||
removeTargets(gpuResources->registeredTargets, changes);
|
||||
@@ -1097,6 +1106,7 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const uint8_t maskMode = properties.maskMode;
|
||||
const uint8_t fixtureMode = properties.fixtureMode;
|
||||
const uint32_t particleCount = properties.particleCount;
|
||||
const float advectionScale = properties.advectionScale;
|
||||
float timelineMix = properties.timeMix;
|
||||
bool cadenceAdvanced = true;
|
||||
uint64_t cadenceRevision = sourceTimelineCadenceRevision;
|
||||
@@ -1264,6 +1274,10 @@ void RenderRasterParticleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
"ParticleValidation30_03: anchors A=0,0 B=0,-90 C=0,-172.8 D=0,172.8 canonical=Mercator-z0");
|
||||
}
|
||||
|
||||
// This is a renderer uniform only. It intentionally preserves State,
|
||||
// Trail, Timeline, and uploaded field textures when changed.
|
||||
resources->advectionScale = advectionScale;
|
||||
|
||||
if (resources->particleCount != particleCount) {
|
||||
const auto previousCount = resources->particleCount;
|
||||
const auto previousSize = resources->stateSize;
|
||||
|
||||
Reference in New Issue
Block a user