Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
IslandApp.hpp
1#include "Terrain.hpp"
2
3#include "Application.hpp"
4#include "input/Input.hpp"
5#include "processing/BoxBlur.hpp"
6#include "resources/ResourcesManager.hpp"
7#include "resources/Texture.hpp"
8#include "graphics/GPU.hpp"
9#include "generation/PerlinNoise.hpp"
10#include "generation/Random.hpp"
11#include "system/Window.hpp"
12#include "system/System.hpp"
13#include "system/Config.hpp"
14#include "Common.hpp"
15
25class IslandApp final : public CameraApp {
26public:
27
33
35 void draw() override;
36
38 void update() override;
39
41 void resize() override;
42
44 ~IslandApp() override;
45
46private:
47
49 struct GerstnerWave {
50 glm::vec4 DiAngleActive = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
51 glm::vec4 AQwp = glm::vec4(0.2f, 0.5f, 0.5f, 0.2f);
52 };
53
55 void generateWaves();
56
57 // Buffers.
65 BoxBlur _blur = BoxBlur(true, "Water");
66
67 // Geometry.
68 std::unique_ptr<Terrain> _terrain;
69 const Mesh * _skyMesh;
72
73 // Textures.
76 const Texture * _foam;
77 const Texture * _brdfLUT;
84
85 // Shaders.
93
94 // Atmosphere options.
95 glm::vec3 _lightDirection;
96 float _lightElevation = 6.0f;
97 float _lightAzimuth = 43.0f;
98 bool _shouldUpdateSky = true;
99
100 // Ocean options.
102 const int _gridOceanRes = 64;
103 float _maxLevelX = 1.0f;
104 float _maxLevelY = 1.0f;
105 float _distanceScale = 1.0f;
106
107 // Debug.
108 bool _showTerrain = true;
109 bool _showOcean = true;
110 bool _showSky = true;
111 bool _stopTime = false;
112 bool _showWire = false;
113};
Window & window()
Definition: Application.cpp:95
Applies a box blur of fixed radius 2. Correspond to uniformly averaging values over a 5x5 square wind...
Definition: BoxBlur.hpp:12
Application with an interactive camera.
Definition: Application.hpp:89
Realistic rendering of a sandy island in the ocean.
Definition: IslandApp.hpp:25
const Mesh * _skyMesh
Sky supporting mesh.
Definition: IslandApp.hpp:69
Program * _groundProgram
Terrain shader.
Definition: IslandApp.hpp:86
bool _showTerrain
Should the terrain be displayed.
Definition: IslandApp.hpp:108
const Texture * _absorbScatterOcean
Precomputed lookup table for ocean absoprtion/scattering.
Definition: IslandApp.hpp:81
Texture _glitterNoise
Specular sand noise.
Definition: IslandApp.hpp:83
bool _shouldUpdateSky
Should the environment map be updated at this frame.
Definition: IslandApp.hpp:98
bool _stopTime
Pause ocean animation.
Definition: IslandApp.hpp:111
BoxBlur _blur
Underwater terrain blurring.
Definition: IslandApp.hpp:65
std::unique_ptr< Terrain > _terrain
Terrain generator and rendering data.
Definition: IslandApp.hpp:68
glm::vec3 _lightDirection
Sun light direction.
Definition: IslandApp.hpp:95
void resize() override
Definition: IslandApp.cpp:543
Texture _sceneDepth
Scene depth.
Definition: IslandApp.hpp:60
Program * _waterCopy
Apply underwater terrain effects (caustics).
Definition: IslandApp.hpp:89
bool _showOcean
Should the ocean be displayed.
Definition: IslandApp.hpp:109
Mesh _oceanMesh
Ocean grid mesh.
Definition: IslandApp.hpp:70
const Texture * _caustics
Caustics texture.
Definition: IslandApp.hpp:74
float _maxLevelY
Maximum subdivision amount.
Definition: IslandApp.hpp:104
bool _showWire
Show debug wireframe.
Definition: IslandApp.hpp:112
~IslandApp() override
Definition: IslandApp.cpp:554
void update() override
Definition: IslandApp.cpp:455
Texture _surfaceNoise
Sand surface normal noise.
Definition: IslandApp.hpp:82
float _lightElevation
Sun angular elevation.
Definition: IslandApp.hpp:96
const Texture * _sandMapFlat
Normal map for flat regions.
Definition: IslandApp.hpp:79
Texture _environment
Environment cubemap.
Definition: IslandApp.hpp:64
const Texture * _foam
Foam texture.
Definition: IslandApp.hpp:76
const Texture * _precomputedScattering
Precomputed lookup table for atmospheric scattering.
Definition: IslandApp.hpp:80
bool _showSky
Should the sky be displayed.
Definition: IslandApp.hpp:110
Program * _farOceanProgram
Distant ocean simplified shader.
Definition: IslandApp.hpp:88
Texture _waterEffectsBlur
Blurred underwater terrain.
Definition: IslandApp.hpp:63
const int _gridOceanRes
Ocean grid resolution.
Definition: IslandApp.hpp:102
Mesh _farOceanMesh
Far ocean supporting cylinder mesh.
Definition: IslandApp.hpp:71
Program * _skyProgram
Atmospheric scattering shader.
Definition: IslandApp.hpp:91
Texture _waterEffectsHalf
Underwater terrain with caustics.
Definition: IslandApp.hpp:61
Program * _underwaterProgram
Underwater rendering.
Definition: IslandApp.hpp:90
Texture _sceneColor
Scene lighting.
Definition: IslandApp.hpp:58
float _distanceScale
Extra distance scaling.
Definition: IslandApp.hpp:105
void generateWaves()
Definition: IslandApp.cpp:114
const Texture * _sandMapSteep
Normal map for steep dunes.
Definition: IslandApp.hpp:78
const Texture * _brdfLUT
Linearized GGX BRDF look-up table.
Definition: IslandApp.hpp:77
Texture _scenePosition
Scene positions.
Definition: IslandApp.hpp:59
Texture _waterPos
Underwater terrain world positions.
Definition: IslandApp.hpp:62
float _lightAzimuth
Sun horizontal orientation.
Definition: IslandApp.hpp:97
Program * _oceanProgram
Ocean shader.
Definition: IslandApp.hpp:87
float _maxLevelX
Maximum level of detail.
Definition: IslandApp.hpp:103
void draw() override
Definition: IslandApp.cpp:152
Program * _tonemap
Tonemapping shader.
Definition: IslandApp.hpp:92
const Texture * _waveNormals
Small waves normal map.
Definition: IslandApp.hpp:75
UniformBuffer< GerstnerWave > _waves
Waves parameters.
Definition: IslandApp.hpp:101
Represents a geometric mesh composed of vertices, other attributes and triangles.
Definition: Mesh.hpp:15
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Configuration containing parameters for windows and renderers.
Definition: Config.hpp:113
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
Represents a buffer containing uniform data, stored on the CPU and GPU. Depending on the update frequ...
Definition: Buffer.hpp:164
Represent an OS window and its associated rendering context.
Definition: Window.hpp:14
Definition: IslandApp.hpp:49
glm::vec4 DiAngleActive
2D direction, angle and flag.
Definition: IslandApp.hpp:50
glm::vec4 AQwp
Gerstner wave parameters.
Definition: IslandApp.hpp:51