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;
124 TextureHandle getRealTex()
const {
return DisplacementTexH; }
129 float getSignificantWaveHeight()
const {
return significantWaveHeight; }
133 int fftTileResolutionLog2 = 7;
134 float significantWaveHeight = 4.f;
135 float dominantWavePeriod = 25.f;
136 float windSpeed = 10.f;
137 float windDirection = 0.f;
140 BasicOceanWaves waves = BasicOceanWaves::Default;
143 float channel0 = std::numeric_limits<float>::quiet_NaN();
144 float channel1 = std::numeric_limits<float>::quiet_NaN();
149 bool specsChanged =
true;
152 bool extraStep =
false;
154 TaskId oceanTaskGroup = NoTask;
156 std::vector<float> P;
171 std::vector<uint8_t> fftScratch1;
172 std::vector<uint8_t> fftScratch2;
173 std::vector<uint8_t> fftScratch3;
174 std::vector<uint8_t> fftScratch4;
175 std::vector<uint8_t> fftScratch5;
177 std::vector<uint8_t> fftScratch;
199 VariableKey phaseShiftNoiseFrequencyKey = NoProperty;
203 void setupMaterial();
208 void setupWaveSpectrum();
210 void updateTextures(
const float magnitudeIn0,
const float magnitudeIn1);
212 void updateTileMaterialInstances(
const BasicOceanData & oceanData,
215 const glm::mat4& viewToWorld,
216 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 destroyComponent(ComponentHandle component) override
Destroy the component held by the given handle.
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.
std::weak_ptr< ComponentModel::Entity > WeakEntityPtr
Weak 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.
Handle to a Component instance.
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.