40 float shiplightCloudOpacity = 0.f;
47 {-iomere.position.x,-iomere.position.y,-iomere.position.z},iomere.scale,
50 {-playerships[0].position.x,-playerships[0].position.y,-playerships[0].position.z},
51 {-Xsunlight.x,-Xsunlight.y,-Xsunlight.z});
62 command.
name =
"AuralHullIonization";
85 logger->
Log(
"----------------------------------- ACMPL");
98 logger->
Log(
"----------------------------------- BCMPL");
137 inview =
Clamp(inview, 0, 1);
152 sprintf_s(
msg,
sizeof(
msg),
"Trapped a violation with shearRate...");
275 auto eyeSample=sample;
277 eyeSample=
CloudVolume::Add(sample,{inverseView._41,inverseView._42,inverseView._43});
288 const auto weatherNow = GetTickCount64();
292 char diagnostic[768];
293 sprintf_s(diagnostic,
sizeof diagnostic,
294 "WEATHER sample settling=%d pendingReset=%d terrainReady=%d terrainPending=%d mslKm=%.6f aglKm=%.6f "
295 "surfaceTargetKm=%.6f surfaceSmoothKm=%.6f ceilingTargetKm=%.6f ceilingSmoothKm=%.6f "
296 "nominalBaseMslKm=%.6f renderedBaseMslKm=%.6f bclKm=%.6f "
297 "visibilityTargetKm=%.6f visibilitySmoothKm=%.6f visibilityKm=%.6f "
298 "cloudActivity=%.6f cloudMapBlend=%.6f",
315 else if (f_temp > 0.0f && f_temp <= 0.05f)
363 const float whereWeThinkWeLeaveOffAt63 = -27.89f;
387 const float snowStartTemp = -1.0f;
388 const float snowEndTemp = 2.0f;
417 float thicknessAboveKm;
421 thicknessAboveKm = -
f_ACL;
423 thicknessAboveKm = 0.0f;
454 bcllight=
RiseMath::Color(scattered.x,scattered.y,scattered.z,bcllight.a);
463 float luma = 0.2126f * bcllight.
r + 0.7152f * bcllight.
g + 0.0722f * bcllight.
b;
467 float desatAmount = precipAttenuation * (1.0f - 0.5f *
snowBlend);
483 float nightVisionFlashStimulus = 0.0f;
513 float r = 0.0f, g = 0.0f, b = 0.0f, avg = 0.0f;
522 f_temp = sqrtf(1.0f - f_temp) * 0.15f;
540 bcllight.
r +=
r / avg;
541 if (bcllight.
r > 1.0f)
543 bcllight.
g += g / avg;
544 if (bcllight.
g > 1.0f)
546 bcllight.
b += b / avg;
547 if (bcllight.
b > 1.0f)
557 luma = 0.2126f * bcllight.
r + 0.7152f * bcllight.
g + 0.0722f * bcllight.
b;
565 if (nightVisionActive)
567 bcllight.
r =
Clamp(bcllight.
r * nvgGain.red, 0.0f, 1.0f);
568 bcllight.
g =
Clamp(bcllight.
g * nvgGain.green, 0.0f, 1.0f);
569 bcllight.
b =
Clamp(bcllight.
b * nvgGain.blue, 0.0f, 1.0f);
578 const auto to=from-Xsunlight*(
radiusC*3);
590 colorzenith.
r = test.
r;
591 colorzenith.
g = test.
g;
592 colorzenith.
b = test.
b;
611 shiplight.
r = 0; shiplight.
g = 0; shiplight.
b = 0;
627 if (effect.
power == 2.0f)
633 else if (effect.
power == 1.5f)
642 else if (effect.
power == 0.5f)
647 shiplight.
r += effect.
diffuse.
r * f_temp;
648 shiplight.
g += effect.
diffuse.
g * f_temp;
649 shiplight.
b += effect.
diffuse.
b * f_temp;
657 shiplight *= sqrtf(
playerships[index].bound / 0.037208f);
676 shipdiff.x = shiplight.
r; shipdiff.y = shiplight.
g; shipdiff.z = shiplight.
b; shipdiff.w = 0;
681 f_temp = sqrtf(bcllight.
r * bcllight.
r + bcllight.
g * bcllight.
g + bcllight.
b * bcllight.
b);
684 f_temp = (1.0f - f_temp) * 0.5f;
701 {unassistedCloudLight.
r,unassistedCloudLight.
g,unassistedCloudLight.
b},{.125f,.375f,.25f},
771 const float gate = 0.25f + 0.75f * base;
823 colorzenith.
a = f_temp;
829 colorzenith.
a = 1.0f;
864 sprintf_s(
msg, 99,
"Weather1 initialized smoothwinddir: %.1f",
smoothwinddir);
900 sprintf_s(
msg, 99,
"Weather initialized smoothPrecipitation: %.1f",
smoothPrecip);
975 return {wind.x,wind.y,wind.z};
984 const uint64_t revision=(uint64_t(header.requestToken)<<32)|header.
revision;
986 auto field=std::make_shared<SpatialFogWeather::Grid>();
987 field->cube=header.cube;field->u=header.tcp.u;field->v=header.tcp.v;field->revision=revision;
988 for(
int y=0;y<64;++y)
for(
int x=0;x<64;++x)
990 const VECTOR2SHORT at(
short(header.tcp.u+x-31),
short(header.tcp.v+y-31));
991 const auto* sample=
plotWeather.
At(header.cube,at,header.requestToken);
992 if(sample && sample->HasVisibility())
993 field->cells[y*64+x]={sample->visibility*.001f,sample->precipitation*.1f};
1074 if (!belowClouds)
return;
1093 packet.
f_y = packet.
f_z = packet.
f_w = 0;
1100 float surfaceMeters;
1130 std::vector<GridLightning::Cell> cells;
1131 cells.reserve(4096);
1132 for (
int q=0;q<64;++q)
for (
int r=0;
r<64;++
r)
1134 const VECTOR2SHORT source(header.tcp.u+q-31,header.tcp.v+
r-31);
1136 if (!sample || !sample->HasVisibility() || sample->ceiling<=0)
continue;
1139 const float surface=
elevation*.001f, base=surface+sample->ceiling*.001f;
1143 if (canonical.u==30000 || canonical.v==30000)
continue;
1146 const float dominant=(std::max)({fabsf(normal.x),fabsf(normal.y),fabsf(normal.z)});
1148 cell.
u=canonical.u; cell.
v=canonical.v;
1152 cell.
area=dominant*dominant*dominant;
1153 cells.push_back(cell);
1167 logger->
Log(
"BOLT: waiting for a current weather grid.");
1185 auto normal=eye+forward;
1188 double u,v;
float surfaceMeters;
1192 logger->
Log(
"BOLT: waiting for terrain 1 km ahead of the camera.");
1202 const float surfaceKm=surfaceMeters*.001f;
1203 if (!std::isfinite(ceilingKm) || ceilingKm<=0 || surfaceKm+ceilingKm>=
cloudTopsMslC)
return false;
1204 const auto ground=normal*(
radiusC+surfaceKm),cloud=normal*(
radiusC+surfaceKm+ceilingKm);
1210 logger->
Log(
"BOLT: local connected lightning ending at ground 1 km ahead of the camera.");
1237 packet.
type=42; packet.
f_x=
event.cell.u; packet.
f_y=
event.cell.v;
1271 auto field=std::make_shared<CloudBaseWeather::Grid>();
1272 field->cube=header.cube;field->u=header.tcp.u;field->v=header.tcp.v;
1273 for(
int y=0;y<64;++y)
for(
int x=0;x<64;++x)
1275 const VECTOR2SHORT point(
short(header.tcp.u+x-31),
short(header.tcp.v+y-31));
1282 field->cells[y*64+x]={(std::min)(8.5f,(
elevation+sample->ceiling)*.001f),
1283 sample->turbulence/255.f,1,0};
1305 if (valid)
for(
int q=0;q<64;++q)
for(
int r=0;
r<64;++
r) {
1308 if(!sample || !sample->HasVisibility())
continue;
1311 if(canonical.u==30000 || canonical.v==30000)
continue;
1315 for(
const auto& column:
gridarray)
for(
const auto& cell:column)
1326 if(u<0 || u>=64 || v<0 || v>=64)
return {0,0,0,0};
1328 if(!cell.elevationAvailable)
return {0,0,0,0};
1332 sqrtf(cell.position.x*cell.position.x+cell.position.y*cell.position.y)));
1340 logger->
Log(
"Weather ForceSmoothValues Called...");
1378 double localU,localV;
float localSurface;
1392 auto grid=std::make_unique<Rendering::CloudRenderer11::RainGrid>();
1393 grid->cells.fill({0,0,42.16f,2});
1395 for(
int q=0;q<64;++q)
for(
int row=0;row<64;++row)
1397 const VECTOR2SHORT at(
short(header.tcp.u+q-31),
short(header.tcp.v+row-31));
1398 const auto* sample=
plotWeather.
At(header.cube,at,header.requestToken);
1404 fog.visibility,fog.precipitation};
1444 if (!std::isfinite(lengthSquared) || lengthSquared <= 0.f)
return 0.f;
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
float Lerp(float val1, float val2, float lerp)
constexpr auto Clamp(T1 val, T2 min, T3 max)
std::vector< Command > commandStream
void Target(GridPtr next)
void Advance(double elapsed)
void UpdateLightning(const CloudVolume::Parameters &value, double elapsed, const CloudVolume::Point &observer={})
void SetLightningEnabled(bool value)
CloudWeather::Frame WeatherFrame()
bool SetLightningDiagnostic(bool enabled)
bool OrganicReady() const
Rendering::CloudRenderer11 * Effect()
void UpdateWeather(const CloudWeather::MapPtr &value, double elapsed)
std::unique_ptr< Bus > bus
std::unique_ptr< Sound > sound
std::unique_ptr< Networking > networking
std::unique_ptr< Graphics > graphics
Rendering::RenderMaterial * g_pEffect
void SetCells(std::vector< Cell > next)
void Observe(const Vector3 &ground)
const Cell * Find(short u, short v) const
bool Update(double elapsed, const Vector3 &observer, int players, float snow, float turbulence, Event &event)
void Log(const char *msg, Level level=Info, int errorCode=0)
void AddToCallStack(const char *msg)
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
CloudWeather::Receiver cloudWeather
Result Accept(const unsigned char *p, size_t length, uint16_t expectedToken)
bool Interpolate(unsigned cube, double u, double v, uint16_t token, LocalSample &result) const
const SRenderWeather * At(unsigned cube, VECTOR2SHORT tcp, uint16_t token) const
const SPlotWeatherHeader & Header() const
void SetRainGrid(const RainGrid *grid)
HRESULT SetVector(const char *name, const RiseMath::Vector4 *value)
void PlayCabinAnnouncement(SOUNDS sound_enum)
void Advance(double elapsed, Point physicalPosition, Point physicalWindKms)
void Accept(GridPtr next, bool full)
uint64_t Generation() const
uint64_t SourceRevision() const
Cell Sample(Point renderPosition) const
void Retain(VECTOR2SHORT p)
const Surface * At(VECTOR2SHORT p) const
void Target(VECTOR2SHORT p, const SRenderWeather &sample)
void Advance(float elapsed)
Rendering::ProceduralLightning11 proceduralLightning
RiseMath::Vector3 position
CloudVolumeRenderer cloudVolume
bool VolumeCloudsEnabled() const
RiseMath::Vector3 compassnorth
bool InventoryItemEffectsEnabled() const
float nightVisionOverexposure
bool m_bDeviceSupportsVizQuery
RiseMath::Matrix matrixLook
RiseMath::Vector3 posnorml
std::unique_ptr< grid > ptrGrid
bool IsRepositionSettling() const
Rendering::Light sunlight
float UniverseRelativeSpeedKms
VECTOR2SHORT CalculateCGC(RiseMath::Vector3 position, char cube) const
RiseMath::Color alphascreen
VECTOR2SHORT CalculateWrap(short u, short v, char cube, char *rotate) const
RiseMath::Vector3 CalculatePlanar(short u, short v)
void TriggerBCLLightningAt(const RiseMath::Vector3 &ground, const RiseMath::Vector3 &cloud, float distanceKm, int seed, int chainedBolts, bool testStrike=false) const
float onlinePlayersInVicinity
RiseMath::Vector3 forwardVector
char CalculateCube(RiseMath::Vector3 position) const
float nightVisionOverexposureHold
float ProbeBoundSphere(RiseMath::Vector3 *position, const RiseMath::Vector3 *Xsunlight) const
uint64_t ElevationRevision() const
bool InterpolateElevation(char face, double u, double v, float &meters) const
bool TryElevation(char face, short u, short v, short &meters) const
RiseMath::Color cockpitRawAmbient
float cloudCeilingOverrideKm
void UpdateLightningSpawns(float elapsed)
RiseMath::Color dwFogFactorZenith
RiseMath::Color vehicleAmbient
void ReceiveGridLightning(short u, short v, int seed, int chainedBolts)
float alphascreenOverride
void SetCloudCeilingTargetKm(float prmCloudCeilingTargetKm)
uint64_t lightningTerrainRevision
uint32_t lightningWeatherRevision
float cloudSurfaceTargetKm
CloudBaseWeather::Store cloudBaseWeather
CloudVolume::Point ObservedWindKms() const
uint64_t cloudBaseTerrainRevision
float GetTurbulence() const
bool RefreshLightningGrid()
void SetCloudSurfaceTargetKm(float prmCloudSurfaceTargetKm)
RiseMath::Color solarHorizon
float cloudCeilingSmoothAglKm
float GetRainPrecip() const
RiseMath::Color dwFogColorZenith
void UpdateTerrainSnow(float elapsed)
void SetPrecip(float prmPrecip)
float GetWindspeedKms() const
void SetTemperatureCelsius(float prmTemperature)
static float SunAttenuation()
RiseMath::Vector4 TerrainSnowTint(int u, int v) const
void FrameMove(float fElapsedTime)
uint16_t cloudBaseRequestToken
void RequestPlotWeather(bool reset)
RiseMath::Color cockpitAmbient
void ResetCloudBaseWeather()
float cloudHorizonDistance
uint16_t snowRequestToken
TerrainSnow::Store terrainSnow
NightVisionGain::Response cockpitVision
float GetNormalizedPrecip()
void QueuePlotWeatherReset()
GridLightning::System gridLightning
RiseMath::Color sunAppearance
void SetWindDirectionRadians(float prmWinddir)
float GetWindDirectionRadians() const
RiseMath::Color betascreen
float GetCloudCeilingKm() const
uint64_t snowTerrainRevision
bool resetLocalCloudWeather
void PrepareRainCurtains(bool exteriorView)
void SetCloudCeilingOverrideKm(float value)
void SetWindspeedKms(float prmWindspeed)
bool TriggerForwardLightning()
bool plotWeatherSuspended
RiseMath::Color cockpitRawCloudLight
RiseMath::Vector4 nightVisionCloudGain
RiseMath::Color colorhorizon
ULONGLONG weatherDiagnosticUntil
CloudVolume::Point cloudSurfaceWind
uint16_t weatherRequestToken
ULONGLONG weatherNextDiagnostic
float cloudCeilingTargetKm
bool weatherRequestQueued
uint32_t snowWeatherRevision
void ReceivePlotWeather(const unsigned char *bytes, size_t length)
void UpdateSpatialFogSnapshot(bool full)
float visibilityOverrideKm
CloudVolume::Parameters cloudParameters
SpatialFogWeather::Store spatialFogWeather
float cloudSurfaceSmoothKm
void SetVisibility(float prmVisibility)
void SetPrecipOverride(float value)
void SetVisibilityOverrideKm(float value)
RiseMath::Color SampleColorGradient(float step, const ColorStop(&stops)[N])
float GetCloudCeilingMslKm() const
void UpdateCloudBaseWeather(float elapsed)
uint32_t cloudBaseWeatherRevision
float cloudTurbulenceBlend
RiseMath::Color dwFogColorHorizon
void AdvanceSpatialFog(float elapsed)
void ResetPlotWeatherConnection()
float GetVisibilityKm() const
float GetTemperatureCelsius() const
float lightningAfterimageAmbient
void UpdatePlotWeatherConditions()
bool UpdatePlotWeatherAltitude()
uint64_t rainTerrainRevision
PlotWeather::Store plotWeather
FIREWORKS fireworks[fireworksC]
s_network_objects playerships[MAX_SCAN]
s_universe_object allobjects[maxstarC]
LIGHTNINGBELOW lightningbelow
s_polygon_object polyobjects[maxpolyC]
LOCALGRID2 gridarray[64][64]
float SolarAngularRadius(float billboardScale, float billboardDistance)
Sphere Configure(bool simulator, Point center, float radius, float solarRadius)
float Visibility(const Sphere &body, Point point, Point towardSun)
float AltitudeWeight(float altitude, float top)
Lighting Evaluate(bool active, bool simulator, CloudVolume::Point scattered, CloudVolume::Point airglow, float sunCosine, float altitude, float base, float top)
Point Add(Point a, Point b)
float AtmosphereWeight(float altitude, float scaleHeight)
void UpdateLocalWeather(Parameters ¶ms, Point &deckWind, bool belowDeck, float base, float activity, Point observedWind, double elapsed, bool reset=false)
Point VehicleAmbient(Point cloudLight, Point skyLight, float altitudeAboveTop)
constexpr float ShiplightScatterDistanceKm
constexpr float ClearVisibilityKm
bool SelectOrganicMode(Parameters ¶ms, bool matchingRendererReady, bool simulator)
float Transmittance(Point from, Point to, const Parameters ¶ms, uint32_t seed=DefaultSeed)
float DiffuseSunTransmission(Point p, Point towardSun, const Parameters ¶ms, uint32_t seed=DefaultSeed)
float ShiplightScatterWeight(float altitude, float deckTop, float scaleHeight, float visibilityKm, float localCloudOpacity)
Column Boundaries(Point p, const Parameters ¶ms, uint32_t seed=DefaultSeed)
Medium SampleMedium(Point p, const Parameters ¶ms, uint32_t seed=DefaultSeed)
float AtmosphericVisibility(float surfaceVisibility, float altitude, float surfaceAltitude, float clearAltitude)
float SunGlareStrength(bool volumeEnabled, float altitudeAboveTop, float visibleSun, float transmission)
float RainDensity(const Medium &medium)
float ScreenOpacity(bool volumeEnabled, float cloudOpacity, float overrideOpacity)
Point ScatteredSunlight(Point incident, float sunCosine, float transmission)
float Sample(const MapPtr &map, float u, float v)
void UV(float x, float y, float z, float &u, float &v)
CloudVolume::Point Ambient(CloudVolume::Point cloudLight, CloudVolume::Point skyLight, float altitudeAboveTop, const NightVisionGain::Response &vision)
float Distance(const Vector3 &a, const Vector3 &b)
constexpr int MaxChainedBolts
float Radiance(float pulse)
void Update(bool active, float flashStimulus, float ambientLuminance, float elapsedSeconds, float &exposure, float &holdSeconds)
Response Calculate(bool active, bool simulator, float luminance)
constexpr unsigned RequestType
bool ParseHeader(const unsigned char *p, size_t length, SPlotWeatherHeader &result)
bool Coordinates(const RiseMath::Vector3 &position, unsigned cube, double &u, double &v)
float Vec3Length(const Vector3 *a)
Color * ColorLerp(Color *out, const Color *a, const Color *b, float t)
float Vec3LengthSq(const Vector3 *a)
Vector3 * Vec3Subtract(Vector3 *out, const Vector3 *a, const Vector3 *b)
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Matrix * MatrixRotationAxis(Matrix *out, const Vector3 *axis, float angle)
float Vec3Dot(const Vector3 *a, const Vector3 *b)
Vector3 * Vec3Normalize(Vector3 *out, const Vector3 *a)
constexpr auto Max(A first, B second)
Point Direction(int cube, double u, double v)
RiseMath::Vector4 Tint(const Surface &surface, float latitude, float sunLatitude)
float Target(float overrideValue, float weatherTarget)
void Apply(float value, float weatherTarget, float &overrideValue, float &smoothValue)
CelestialEclipse::Sphere eclipse
CloudWeather::Frame weather
CloudBaseWeather::Frame localBase
RiseMath::Vector3 position
void Update(double elapsed)
RiseMath::Vector3 Direction
int inventoryItemInUseSubType
int inventoryItemInUseType
RiseMath::Vector3 barycentric
RiseMath::Vector3 position
RiseMath::Vector3 velocity
std::vector< s_light_effect > effects