5#include "Systems/ComponentSystem.h"
7#include "Platform/Instrumentation.h"
9#include "Components/Appearance/BasicOceanComponent.h"
11#include "Resources/Resources.h"
13#include "Services/TaskManager.h"
24 float transparency = 0.0;
26 float reflectionBrightness = 1.f;
29 bool transparent =
false;
30 bool initialized =
false;
32 const char * encoding =
nullptr;
33 const char * waveVariant =
nullptr;
34 const char * beliefSystem =
nullptr;
35 const char * reflectionVariant =
nullptr;
36 const char* lightModelVariant =
nullptr;
59 storage.resize((2 * N *
sizeof(
float) +
sizeof(Chunk) - 1) /
sizeof(Chunk));
69 return reinterpret_cast<float*
>(storage.data());
72 const float* real()
const
74 return reinterpret_cast<const float*
>(storage.data());
79 return reinterpret_cast<float*
>(storage.data()) + N;
82 const float* imag()
const
84 return reinterpret_cast<const float*
>(storage.data()) + N;
87 std::complex<float> load(
const size_t index)
const
89 return std::complex<float>(
reinterpret_cast<const float*
>(storage.data())[index],
90 reinterpret_cast<const float*
>(storage.data())[N + index]);
93 void store(
const size_t index,
const std::complex<float> value)
95 reinterpret_cast<float*
>(storage.data())[index] = std::real(value);
96 reinterpret_cast<float*
>(storage.data())[N + index] = std::imag(value);
101 _declspec(align(32))
struct Chunk { uint8_t data[32]; };
102#elif defined(__GNUC__) || defined(__clang__)
103 struct Chunk { uint8_t data[32]; } __attribute__((aligned(32)));
107 std::vector<Chunk> storage;
120 TextureHandle getRealTex()
const {
return DisplacementTexH; }
125 float getSignificantWaveHeight()
const {
return significantWaveHeight; }
129 int fftTileResolutionLog2 = 7;
130 float significantWaveHeight = 4.f;
131 float dominantWavePeriod = 25.f;
132 float windSpeed = 10.f;
133 float windDirection = 0.f;
136 BasicOceanWaves waves = BasicOceanWaves::Default;
139 float channel0 = std::numeric_limits<float>::quiet_NaN();
140 float channel1 = std::numeric_limits<float>::quiet_NaN();
145 bool specsChanged =
true;
148 bool extraStep =
false;
150 TaskId oceanTaskGroup = NoTask;
152 std::vector<float> P;
167 std::vector<uint8_t> fftScratch1;
168 std::vector<uint8_t> fftScratch2;
169 std::vector<uint8_t> fftScratch3;
170 std::vector<uint8_t> fftScratch4;
171 std::vector<uint8_t> fftScratch5;
173 std::vector<uint8_t> fftScratch;
195 VariableKey phaseShiftNoiseFrequencyKey = NoProperty;
199 void setupMaterial();
202 void setupWaveSpectrum();
204 void updateTextures(
const float magnitudeIn0,
const float magnitudeIn1);
206 void updateTileMaterialInstances(
const BasicOceanData & oceanData,
209 const glm::mat4& viewToWorld,
210 const glm::vec2& viewPortSize);
void initialize(Context *context) override
Initialize the system.
unsigned int tilePeriod
Number of FFT-tiles before ocean repeats itself.
bool eightBit
Use eight bit texture format for wave displacement.
unsigned int phaseShiftNoiseFrequency
Frequency of phase shift noise wrt FFT tile size.
void cleanup(Context *context) override
Provided for custom cleanup logic in derived systems.
float fftTileExtent
Size of FFT-tile in meters, set up setupWaveSpectrum.
Context * context
Pointer to the Context instance the system lives in.
void postUpdate()
Perform post update logic in the system.
void update()
Updates the system state to that of the current frame.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Base allocator implementation.
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
uint16_t VariableKey
Used to lookup material properties.
Contains all Cogs related functionality.
ComponentIndex SizeType
Type used to track the size of pools.
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.
Task id struct used to identify unique Task instances.