H3D API  2.4.1
ConvolutionFilterShader.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // Any use, or distribution, of this file without permission from the
5 // copyright holders is strictly prohibited. Please contact SenseGraphics,
6 // www.sensegraphics.com, for more information.
7 //
8 //
12 //
14 #ifndef __CONVOLUTIONFILTERSHADER_H__
15 #define __CONVOLUTIONFILTERSHADER_H__
16 
17 #include <H3D/MFFloat.h>
19 #include <H3D/FieldTemplates.h>
20 
21 namespace H3D {
22 
76  public:
77 
84  true >
86 
87  class TextureMonitor: public OnValueChangeSField<SFInt32>
88  {
89  public:
90  virtual void onValueChange( const int &new_value ){
91  ConvolutionFilterShader* _owner = dynamic_cast<ConvolutionFilterShader*> (getOwner());
92  _owner->buildShader();
93  }
94  };
95 
97  ConvolutionFilterShader( Inst< DisplayList > _displayList = 0,
98  Inst< SFNode > _metadata = 0,
99  Inst< SFBool > _isSelected = 0,
100  Inst< SFBool > _isValid = 0,
101  Inst< SFBool > _activate = 0,
102  Inst< SFString > _language = 0,
103  Inst< MFShaderPart > _parts = 0,
104  Inst< SFBool > _suppressUniformWarnings = 0,
105  Inst< MFString > _fragmentShaderString = 0,
106  Inst< MFString > _vertexShaderString = 0,
107  Inst< SFTexture2DNode > _texture = 0,
108  Inst< SFString > _type = 0,
109  Inst< MFFloat > _weights = 0,
110  Inst< SFInt32 > _kernelSize = 0,
111  Inst< SFFloat > _pixelStepOffset = 0,
112  Inst< SFInt32> _width = 0,
113  Inst< SFInt32> _height = 0,
114  Inst< TextureMonitor> _widthInUse = 0,
115  Inst< TextureMonitor> _heightInUse = 0 );
116 
122  H3DUniquePtr< SFTexture2DNode > texture;
123 
141  H3DUniquePtr< SFString > type;
142 
150  H3DUniquePtr< MFFloat > weights;
151 
159  H3DUniquePtr< SFInt32 > kernelSize;
160 
172  H3DUniquePtr< SFFloat > pixelStepOffset;
173 
179  H3DUniquePtr< SFInt32 > width;
187  H3DUniquePtr< SFInt32 > height;
188 
190  H3DUniquePtr< TextureMonitor > widthInUse;
191 
193  H3DUniquePtr< TextureMonitor > heightInUse;
194 
196  virtual void traverseSG( TraverseInfo &ti );
197 
200  protected:
201 
202 
205  virtual bool canBuildShader();
206 
208  virtual void buildShader();
209 
214  string addUniformFields( ComposedShader *shader );
215 
217  virtual string getFragmentShaderString();
218 
222  virtual string getFragmentShaderHeader() { return "#version 150 compatibility"; } // using 150 to be able to use the compatability keyword. 130 should be enough otherwise.
223 
225  virtual string getVertexShaderHeader() { return "#version 150 compatibility"; }
226 
227  };
228 }
229 
230 #endif
Contains different templates to modify field behaviour.
Header file for H3DGeneratedFragmentShaderNode.
Contains the MFFloat field class.
The ComposedShader node defines a shader where the individual source files are not individually progr...
Definition: ComposedShader.h:77
The ConvolutionFilterShader node generates a shader that applies a convolution filter kernel to the i...
Definition: ConvolutionFilterShader.h:75
virtual string getVertexShaderHeader()
Use version 150 compatibility for ConvolutionFilterShader.
Definition: ConvolutionFilterShader.h:225
H3DUniquePtr< SFFloat > pixelStepOffset
The pixelStepOffset is used to add customized offset to the pixel step using in convolving,...
Definition: ConvolutionFilterShader.h:172
H3DUniquePtr< SFInt32 > kernelSize
The kernelSize field specifies the size convolution kernel.
Definition: ConvolutionFilterShader.h:159
H3DUniquePtr< MFFloat > weights
The weight field specifies the values in the convolution kernel.
Definition: ConvolutionFilterShader.h:150
virtual string getFragmentShaderHeader()
Return a string that is placed at the beginning of a fragment shader to specify minimum required vers...
Definition: ConvolutionFilterShader.h:222
H3DUniquePtr< TextureMonitor > heightInUse
Actual height used in convolution filter shader.
Definition: ConvolutionFilterShader.h:193
DependentSFNode< H3DSingleTextureNode, FieldRef< H3DDisplayListObject, H3DDisplayListObject::DisplayList, &H3DDisplayListObject::displayList >, true > SFTexture2DNode
The SFTexture2DNode field is dependent on the displayList field of the containing X3DTexture2DNode no...
Definition: ConvolutionFilterShader.h:85
H3DUniquePtr< SFTexture2DNode > texture
The texture field contains the texture on which to apply the filter kernel.
Definition: ConvolutionFilterShader.h:122
H3DUniquePtr< SFInt32 > width
The height of the window size this shader is going to apply to.
Definition: ConvolutionFilterShader.h:179
H3DUniquePtr< SFInt32 > height
The width of the window size this shader is going to apply to.
Definition: ConvolutionFilterShader.h:187
H3DUniquePtr< TextureMonitor > widthInUse
Actual width used in convolution filter shader.
Definition: ConvolutionFilterShader.h:190
H3DUniquePtr< SFString > type
Some kernels(e.g.
Definition: ConvolutionFilterShader.h:141
virtual void buildShader()
Overriding buildShader to only build the shader if canBuildShader is true.
Definition: ConvolutionFilterShader.cpp:145
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ConvolutionFilterShader.h:199
DependentSFNode are modified TypedSFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:294
Class used for specifying a field member of a node in a DependentSFNode or DependentMFNode specificat...
Definition: DependentNodeFields.h:48
We use the Field's lazy evaluation mechanisms to manage the GL display lists for rendering,...
Definition: H3DDisplayListObject.h:60
This abstract interface class is the base class for all node types that wants to create an OpenGL dis...
Definition: H3DDisplayListObject.h:54
H3DUniquePtr< DisplayList > displayList
The DisplayList instance handling the OpenGL caching of this object.
Definition: H3DDisplayListObject.h:256
The H3DGeneratedFragmentShaderNode node is the base class for shader generator nodes that specify a f...
Definition: H3DGeneratedFragmentShaderNode.h:44
This abstract node type is the base type for all texture nodes that is defined by a single texture.
Definition: H3DSingleTextureNode.h:45
Template for adding the virtual function onValueChange that can be overridden in subclasses in order ...
Definition: FieldTemplates.h:49
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194