MeshLib
 
Loading...
Searching...
No Matches
MRShadowsGL.h
Go to the documentation of this file.
1#pragma once
2#include "MRViewerFwd.h"
3#include "MRMesh/MRVector2.h"
4#include "MRMesh/MRVector4.h"
5#include "MRMesh/MRColor.h"
6#include "MRRenderGLHelpers.h"
7#include <boost/signals2/connection.hpp>
8
9namespace MR
10{
11
12// This class allows do draw shadows for objects in scene
13// draws scene into texture buffer, than make shadow from:
14// draw shadow and than draw texture with scene
15class MRVIEWER_CLASS ShadowsGL
16{
17public:
19 MRVIEWER_API ~ShadowsGL();
20
21 // subscribe to viewer events on enable, unsubscribe on disable
22 MRVIEWER_API void enable( bool on );
23 bool isEnabled() const { return enabled_; }
24
25 // shift in screen space
26 const Vector2f& getShadowShift() const { return shadowShift_; }
27 MRVIEWER_API void setShadowShift( const Vector2f& shift );
28
29 const Vector4f& getShadowColor() const { return shadowColor_; }
30 MRVIEWER_API void setShadowColor( const Vector4f& color );
31
32 float getBlurRadius() const { return blurRadius_; }
33 MRVIEWER_API void setBlurRadius( float radius );
34
35 // value that describes blur quality, blur texture downscaling coefficient
36 // (0,1] 1 - is maximum quality, but it can affect performance on embedded systems
37 // 0.25 - recommended value
38 float getQuality() const { return quality_; }
39 MRVIEWER_API void setQuality( float quality );
40private:
41 // shift in screen space
42 Vector2f shadowShift_ = Vector2f( 0.0, 0.0 );
43 Vector4f shadowColor_ = Vector4f( Color::yellow() );
44 float blurRadius_{ 40.0f };
45
46 float quality_{ 0.25f };
47 void preDraw_();
48 void postDraw_();
49 void postResize_( int x, int y );
50
51 void drawLowSize_();
52 void convolveX_();
53 void convolveY_();
54 void drawShadow_( bool convX );
55 void drawTexture_( bool scene, bool downsample );
56
57 boost::signals2::connection preDrawConnection_;
58 boost::signals2::connection postDrawConnection_;
59 boost::signals2::connection postResizeConnection_;
60
61 Vector2i sceneSize_;
62 Vector2i lowSize_;
63
64 QuadTextureVertexObject quadObject_;
65
66 FramebufferData sceneFramebuffer_;
67 FramebufferData lowSizeFramebuffer_;
68 FramebufferData convolutionXFramebuffer_;
69
70 bool enabled_{ false };
71};
72
73}
Definition MRShadowsGL.h:16
const Vector4f & getShadowColor() const
Definition MRShadowsGL.h:29
float getQuality() const
Definition MRShadowsGL.h:38
MRVIEWER_API ~ShadowsGL()
MRVIEWER_API void setShadowShift(const Vector2f &shift)
const Vector2f & getShadowShift() const
Definition MRShadowsGL.h:26
MR_ADD_CTOR_DELETE_MOVE(ShadowsGL)
MRVIEWER_API void setBlurRadius(float radius)
MRVIEWER_API void setShadowColor(const Vector4f &color)
MRVIEWER_API void enable(bool on)
float getBlurRadius() const
Definition MRShadowsGL.h:32
MRVIEWER_API void setQuality(float quality)
bool isEnabled() const
Definition MRShadowsGL.h:23
Definition MRCameraOrientationPlugin.h:7