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
141
142
143
144
/*
   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();

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

    void updateResolution(U16 newWidth, U16 newHeight);

    inline void pushFilter(FilterType filter) {
        ++_filterStackCount[to_U32(filter)];
        _filtersDirty = true;
    }

    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_U32(filter)] > 0) {
            --_filterStackCount[to_U32(filter)];
            _filtersDirty = true;
        }
    }

    inline bool getFilterState(FilterType filter) const {
        return _filterStackCount[to_U32(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 UColour& 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 UColour& targetColour, D64 durationMS, D64 waitDurationMS);
    void setFadeOutIn(const UColour& 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;
    bool _filtersDirty;

    GenericDrawCommand _drawCommand;
    Pipeline* _drawPipeline = nullptr;
    PushConstants _drawConstants;
END_SINGLETON

};  // namespace Divide

#endif

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

Diff revisions: vs.
Revision Author Commited Message
1004 Diff Diff IonutCava picture IonutCava Wed 20 Dec, 2017 17:16:32 +0000

[Ionut]
- More GUI cleanup (added multiple GUIButton events)
- Typedef vec4<U8> and vec4<F32> to UColour and FColour respectively for easier to read code.

968 Diff Diff IonutCava picture IonutCava Tue 07 Nov, 2017 17:32:31 +0000

[Ionut]
- Consistent naming between timing variables

953 Diff Diff IonutCava picture IonutCava Sat 28 Oct, 2017 21:57:10 +0000

[Ionut]
- Fix blinking issue by caching and hashing pipelines to that we don’t overwrite pipelines used by other elements

933 Diff Diff IonutCava picture IonutCava Tue 15 Aug, 2017 00:02:05 +0000

[Ionut]
- CommandBuffer Part 2/3: code compiles and splash screen renders and application doesn’t crash (still has drawing issues)

929 Diff Diff IonutCava picture IonutCava Sat 12 Aug, 2017 17:34:44 +0000

[Ionut]
- More work on finishing up new PushConstant / Command buffer rendering system:
— Everything compiles and runs but with graphical and performance issues

893 Diff Diff IonutCava picture IonutCava Sun 18 Jun, 2017 17:33:07 +0000

[Ionut]
- Initial implementation of a PipelineStateObject (holds shader program, rasterizer state, etc)
- Rework PCH implementation a bit because VS2017 no longer has a /ZM option

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

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 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