Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _POST_EFFECTS_H
#define _POST_EFFECTS_H

#include "PreRenderBatch.h"
#include "Core/Math/Headers/MathVectors.h"

namespace Divide {

class Quad3D;
class Camera;
class GFXDevice;
class ShaderProgram;
class Texture;

DEFINE_SINGLETON(PostFX)
   private:
      enum class TexOperatorBindPoint : U32 {
          TEX_BIND_POINT_SCREEN = 0,
          TEX_BIND_POINT_BORDER = 1,
          TEX_BIND_POINT_NOISE = 2,
          TEX_BIND_POINT_UNDERWATER = 3,
          COUNT
      };

  private:
    PostFX();
    ~PostFX();

  public:
    void apply(GFXDevice& context);

    void init(GFXDevice& context, ResourceCache& cache);
    void idle(const Configuration& config);
    void update(const U64 deltaTime);

    void updateResolution(U16 newWidth, U16 newHeight);

    inline void pushFilter(FilterType filter) {
        ++_filterStackCount[to_uint(filter)];
    }

    inline void popFilter(FilterType filter) {
        // Since this is scriptable, we may pop without a previous push
        // just to make sure we are in a proper state
        if (_filterStackCount[to_uint(filter)] > 0) {
            --_filterStackCount[to_uint(filter)];
        }
    }

    inline bool getFilterState(FilterType filter) const {
        return _filterStackCount[to_uint(filter)] > 0;
    }

    // fade the screen to the specified colour lerping over the specified time interval
    // set durationMS to instantly set fade colour
    // optionally, set a callback when fade out completes
    // waitDurationMS = how much time to wait vefore calling the completeion callback after fade out completes
    void setFadeOut(const vec4<U8>& targetColour, D64 durationMS, D64 waitDurationMS, DELEGATE_CBK<void> onComplete = DELEGATE_CBK<void>());
    // clear any fading effect currently active over the specified time interval
    // set durationMS to instantly clear the fade effect
    // optionally, set a callback when fade in completes
    void setFadeIn(D64 durationMS, DELEGATE_CBK<void> onComplete = DELEGATE_CBK<void>());
    // fade out to specified colour and back again within the given time slice
    // if duration is 0.0, nothing happens
    // waitDurationMS is the ammount of time to wait before fading back in
    void setFadeOutIn(const vec4<U8>& targetColour, D64 durationMS, D64 waitDurationMS);
    void setFadeOutIn(const vec4<U8>& targetColour, D64 durationFadeOutMS, D64 durationFadeInMS, D64 waitDurationMS);

    inline void cacheDisplaySettings(const GFXDevice& context) {
        PreRenderOperator::cacheDisplaySettings(context);
    }
  private:

    PreRenderBatch* _preRenderBatch;
    /// Screen Border
    Texture_ptr _screenBorder;
    /// Noise
    Texture_ptr _noise;

    F32 _randomNoiseCoefficient, _randomFlashCoefficient;
    D64 _noiseTimer, _tickInterval;

    ShaderProgram_ptr _postProcessingShader;
    Texture_ptr _underwaterTexture;
    GFXDevice* _gfx;
    vec2<U16> _resolutionCache;
    vectorImpl<U32> _shaderFunctionSelection;
    vectorImpl<I32> _shaderFunctionList;

    RTDrawDescriptor _postFXTarget;

    //fade settings
    D64 _currentFadeTimeMS;
    D64 _targetFadeTimeMS;
    D64 _fadeWaitDurationMS;
    bool _fadeOut;
    bool _fadeActive;
    DELEGATE_CBK<void> _fadeOutComplete;
    DELEGATE_CBK<void> _fadeInComplete;

    FilterStack _filterStackCount;


    GenericDrawCommand _drawCommand;
END_SINGLETON

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Rendering/PostFX/Headers/PostFX.h

Diff revisions: vs.
Revision Author Commited Message
842 Diff Diff IonutCava picture IonutCava Wed 01 Feb, 2017 17:25:15 +0000

[IonutCava]
- Start to implement scripting support via ChaiScript: http://chaiscript.com/
- Cleanup DELEGATE_CBK alias

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

830 Diff Diff IonutCava picture IonutCava Wed 25 Jan, 2017 17:29:44 +0000

[IonutCava]
- Add a new Platform element: File
— Move all predefined paths to FileManagement System
- Split MathHelper into MathHelper and StringHelper

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
801 Diff Diff IonutCava picture IonutCava Sun 27 Nov, 2016 21:28:01 +0000

[IonutCava]
- More performance analysis guided optimizations.
- Some refactoring to allow later removal of Singletons status for: GFXDevice, SFXDevice, PXDevice, GUI and Input.
— Pass a PlatformContext around objects to access these classes.

791 Diff Diff IonutCava picture IonutCava Thu 17 Nov, 2016 16:46:19 +0000

[IonutCava]
- Reworked PostFX filter list to allow multiple enable calls to the same effect (stack based)
- Added noise, vignette and underwater effects to the filter list available for PostFX
- Added better underwater camera detection

734 Diff Diff IonutCava picture IonutCava Tue 21 Jun, 2016 16:28:11 +0000

[IonutCava]
- Added a render target pool:
— All render targets are now allocated (and tracked) by the GFXDevice.
— Allocation routines return a slim RenderTargetHandle object that will be used later on in draw commands.

- Added a refraction render pass that will handle translucent objects that need refracted textures instead of clear transparency
— Both reflective nodes and refractive nodes are not gathered properly at this point

- All API specific objects (buffers, textures, etc) are now initialized in the GFXDevice class (see GFXDeviceObjects.cpp)
— This allowed for the slimming of the RenderAPIWrapper interface

- Improved ENABLE_GPU_VALIDATION macro utilization:
— It enabled shadow map split plane debugging
— It bypasses loading shaders from text cache

722 Diff Diff IonutCava picture IonutCava Thu 09 Jun, 2016 16:15:33 +0000

[IonutCava]
- Restructure RenderTarget system:
— Separate attachments, use an attachment pool, use draw descriptors, require explicit information for RT calls, etc

718 Diff Diff IonutCava picture IonutCava Thu 02 Jun, 2016 16:02:48 +0000

[IonutCava]
- Code cleanup:
— Rename Framebuffer to RenderTarget. Only OpenGL uses the Framebuffer nomenclature.
— Remove base Shader class as only OpenGL will have separate shaders (and eventually move to pipeline objects) as Direct3D uses FX files and may end up with different structure
— Remove drawBox3D, drawSphere3D and drawLines from GFXDevice class and add them as member functions to the IMPrimitive class (renamed to fromXYZ)
— Pull some elements from SceneManager and move them to standalone classes (W.I.P.)

715 IonutCava picture IonutCava Fri 27 May, 2016 16:19:22 +0000

[IonutCava]
- Added initial Fade In / Fade Out post effect (used for scene transitions for now)
- Added a GUI Interface that handles a list of GUI elements (used by GUI and SceneGUIElements)
- Fixed some race conditions related to multi-threaded scene loading (a lot remain to be fixed)
- Improved per-thread GPU sync system a bit
- Simplified Singleton define macros (although we should get rid of singletons all together)