Skip to content

Commit 32bc650

Browse files
committed
basic screen space effects
1 parent 4244eac commit 32bc650

File tree

6 files changed

+195
-139
lines changed

6 files changed

+195
-139
lines changed

sources/include/cage-engine/sceneScreenSpaceEffects.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ namespace cage
1010
None = 0,
1111
AmbientOcclusion = 1 << 0,
1212
DepthOfField = 1 << 1,
13-
Bloom = 1 << 3,
14-
EyeAdaptation = 1 << 4,
15-
ToneMapping = 1 << 5,
16-
GammaCorrection = 1 << 6,
17-
AntiAliasing = 1 << 7,
18-
Sharpening = 1 << 8,
13+
Bloom = 1 << 2,
14+
ToneMapping = 1 << 3,
15+
GammaCorrection = 1 << 4,
16+
AntiAliasing = 1 << 5,
17+
Sharpening = 1 << 6,
1918
Default = AmbientOcclusion | Bloom | ToneMapping | GammaCorrection | AntiAliasing,
2019
};
2120

2221
struct CAGE_ENGINE_API ScreenSpaceEffectsComponent
2322
{
2423
ScreenSpaceAmbientOcclusion ssao;
2524
ScreenSpaceBloom bloom;
26-
ScreenSpaceEyeAdaptation eyeAdaptation;
2725
ScreenSpaceDepthOfField depthOfField;
2826
ScreenSpaceSharpening sharpening;
2927
Real gamma = 2.2;
Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,68 @@
11
#ifndef guard_screenSpaceEffects_h_xcfvh241448960sdrt
22
#define guard_screenSpaceEffects_h_xcfvh241448960sdrt
33

4-
/*
5-
6-
#include <cage-engine/provisionalHandles.h>
74
#include <cage-engine/screenSpaceEffectsProperties.h>
85

96
namespace cage
107
{
11-
class RenderQueue;
12-
class AssetsManager;
13-
class ProvisionalGraphics;
8+
class GraphicsEncoder;
9+
class Texture;
1410

1511
struct CAGE_ENGINE_API ScreenSpaceCommonConfig
1612
{
17-
RenderQueue *queue = nullptr;
13+
GraphicsEncoder *encoder = nullptr;
1814
AssetsManager *assets = nullptr;
19-
ProvisionalGraphics *provisionals = nullptr;
2015
Vec2i resolution;
2116
};
2217

2318
struct CAGE_ENGINE_API ScreenSpaceAmbientOcclusionConfig : public ScreenSpaceCommonConfig, public ScreenSpaceAmbientOcclusion
2419
{
2520
Mat4 proj;
26-
TextureHandle inDepth;
27-
mutable TextureHandle outAo;
21+
Texture *inDepth = nullptr;
22+
Texture *outAo = nullptr;
2823
uint32 frameIndex = 0;
2924
};
3025

3126
struct CAGE_ENGINE_API ScreenSpaceDepthOfFieldConfig : public ScreenSpaceCommonConfig, public ScreenSpaceDepthOfField
3227
{
3328
Mat4 proj;
34-
TextureHandle inDepth;
35-
TextureHandle inColor;
36-
TextureHandle outColor;
37-
};
38-
39-
struct CAGE_ENGINE_API ScreenSpaceEyeAdaptationConfig : public ScreenSpaceCommonConfig, public ScreenSpaceEyeAdaptation
40-
{
41-
String cameraId; // for synchronizing data across frames
42-
TextureHandle inColor; // used in both passes
43-
TextureHandle outColor; // used in the apply pass only
44-
Real elapsedTime = 1.0 / 60;
29+
Texture *inDepth = nullptr;
30+
Texture *inColor = nullptr;
31+
Texture *outColor = nullptr;
4532
};
4633

4734
struct CAGE_ENGINE_API ScreenSpaceBloomConfig : public ScreenSpaceCommonConfig, public ScreenSpaceBloom
4835
{
49-
TextureHandle inColor;
50-
TextureHandle outColor;
36+
Texture *inColor = nullptr;
37+
Texture *outColor = nullptr;
5138
};
5239

5340
struct CAGE_ENGINE_API ScreenSpaceTonemapConfig : public ScreenSpaceCommonConfig
5441
{
55-
TextureHandle inColor;
56-
TextureHandle outColor;
42+
Texture *inColor = nullptr;
43+
Texture *outColor = nullptr;
5744
Real gamma = 2.2;
5845
bool tonemapEnabled = true;
5946
};
6047

6148
struct CAGE_ENGINE_API ScreenSpaceFastApproximateAntiAliasingConfig : public ScreenSpaceCommonConfig
6249
{
63-
TextureHandle inColor;
64-
TextureHandle outColor;
50+
Texture *inColor = nullptr;
51+
Texture *outColor = nullptr;
6552
};
6653

6754
struct CAGE_ENGINE_API ScreenSpaceSharpeningConfig : public ScreenSpaceCommonConfig, public ScreenSpaceSharpening
6855
{
69-
TextureHandle inColor;
70-
TextureHandle outColor;
56+
Texture *inColor = nullptr;
57+
Texture *outColor = nullptr;
7158
};
7259

7360
CAGE_ENGINE_API void screenSpaceAmbientOcclusion(const ScreenSpaceAmbientOcclusionConfig &config);
7461
CAGE_ENGINE_API void screenSpaceDepthOfField(const ScreenSpaceDepthOfFieldConfig &config);
75-
CAGE_ENGINE_API void screenSpaceEyeAdaptationPrepare(const ScreenSpaceEyeAdaptationConfig &config);
7662
CAGE_ENGINE_API void screenSpaceBloom(const ScreenSpaceBloomConfig &config);
77-
CAGE_ENGINE_API void screenSpaceEyeAdaptationApply(const ScreenSpaceEyeAdaptationConfig &config);
7863
CAGE_ENGINE_API void screenSpaceTonemap(const ScreenSpaceTonemapConfig &config);
7964
CAGE_ENGINE_API void screenSpaceFastApproximateAntiAliasing(const ScreenSpaceFastApproximateAntiAliasingConfig &config);
8065
CAGE_ENGINE_API void screenSpaceSharpening(const ScreenSpaceSharpeningConfig &config);
8166
}
8267

83-
*/
84-
8568
#endif // guard_screenSpaceEffects_h_xcfvh241448960sdrt

sources/include/cage-engine/screenSpaceEffectsProperties.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ namespace cage
2727
uint32 blurPasses = 3;
2828
};
2929

30-
struct CAGE_ENGINE_API ScreenSpaceEyeAdaptation
31-
{
32-
Real darkerSpeed = 1;
33-
Real lighterSpeed = 2;
34-
Real lowLogLum = -12;
35-
Real highLogLum = 2;
36-
Real nightOffset = 3;
37-
Real nightDesaturate = 0.2;
38-
Real nightContrast = 0.01;
39-
Real key = 0.1; // target gray
40-
Real strength = 0.8; // whole effect factor
41-
};
42-
4330
struct CAGE_ENGINE_API ScreenSpaceBloom
4431
{
4532
uint32 blurPasses = 5;

sources/libengine/graphics/encoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ namespace cage
128128
{
129129
wgpu::ColorTargetState cts = {};
130130
cts.format = ct.texture->nativeTexture().GetFormat();
131-
cts.blend = &blendState;
131+
if (config.blending != BlendingEnum::None)
132+
cts.blend = &blendState;
132133
colors.push_back(cts);
133134
}
134135

0 commit comments

Comments
 (0)