Beatmup
|
Generates GLSL fragment shader code sampling a local neighborhood around the current texture coordinates for further filtering. More...
#include <operation.h>
Protected Member Functions | |
SpatialFilteringMixin (const int nbSizeX, const int nbSizeY) | |
Initializes spatial filtering mixin. More... | |
~SpatialFilteringMixin () | |
void | writeHeader (StringBuilder &code, bool useUniformShift) |
Writes out the very GLSL fragment shader header required for spatial neighborhood sampling. More... | |
void | declare (StringBuilder &code, const char *datatype, bool inlineSampling=false) |
Declares GLSL fragment shader main(..) code part required for spatial neighborhood sampling. More... | |
void | sample (StringBuilder &code, const char *inputName, const int inputIndex, const Point &shift, const bool isFirstSample=true, const char *suffix="") |
Samples a neighborhood of a given texture. More... | |
void | sampleInline (StringBuilder &code, const char *inputName, const int inputIndex, const IntPoint &position, const Point &shift, const char *suffix="") |
void | setup (const int width, const int height) |
Prepares the spatial filtering operation execution. More... | |
void | setUniformShift (GL::Program &program, const IntPoint &shift, const IntPoint &inputSize) |
Applies an offset to the sampling position at runtime. More... | |
void | setupProgram (GL::Program &program) |
Prepares a given program for spatial filtering. More... | |
IntRectangle | getSamplingArea (const IntPoint &size, const IntPoint &stride, const Size::Padding padding) const |
Implements common padding policies by computing a rectangular area of positions the sampling kernel takes in order to get the result with the required padding. More... | |
IntRectangle | getSamplingArea (const Storage::View &storage, const int channel, const IntPoint &stride, const Size::Padding padding) const |
Computes area in pixels to sample a given storage according to specific stride and padding. More... | |
Rectangle | getTextureCoordinates (const Storage::View &storage, const int channel, const IntPoint &stride, const Size::Padding padding, const IntPoint &outputSize) const |
Computes texture coordinates sampling a specific storage channel for given stride, padding and output size. More... | |
std::string | getInputSamplingPos () const |
Retrieves input sampling point position for the current fragment. More... | |
bool | isUniformShiftUsed () const |
Static Protected Attributes | |
static const char * | SAMPLE_ID_PREFIX = "i" |
prefix of variables declaring a neighbor sample More... | |
Private Member Functions | |
int | getDeltasSize () const |
Private Attributes | |
const int | nbSizeX |
const int | nbSizeY |
Point | shift |
current static shift of the sampling position More... | |
float * | deltas |
array storing pixel position differences for neighborhood sampling More... | |
bool | useUniformShift |
if true , the sampling position can be shifted dynamically at every run More... | |
Generates GLSL fragment shader code sampling a local neighborhood around the current texture coordinates for further filtering.
Definition at line 272 of file operation.h.
|
protected |
Initializes spatial filtering mixin.
[in] | nbSizeX | Neighborhood width in samples |
[in] | nbSizeY | Neighborhood height in samples |
Definition at line 98 of file operation.cpp.
|
protected |
Definition at line 105 of file operation.cpp.
|
inlineprivate |
Definition at line 282 of file operation.h.
|
protected |
Writes out the very GLSL fragment shader header required for spatial neighborhood sampling.
[in,out] | code | The GLSL code storage |
[in] | useUniformShift | If true , the sampling position can be shifted dynamically at every run |
Definition at line 110 of file operation.cpp.
|
protected |
Declares GLSL fragment shader main(..) code part required for spatial neighborhood sampling.
[in,out] | code | The GLSL code storage |
[in] | datatype | The neighborhood samples datatype |
[in] | inlineSampling | If true , sampled values are not stored in intermediate variables (sampleInline() can only be used, not sample()) |
Definition at line 119 of file operation.cpp.
|
protected |
Samples a neighborhood of a given texture.
[in,out] | code | The GLSL code storage |
[in] | inputName | The texture sampler array variable name |
[in] | inputIndex | Index of the texture in the array |
[in] | shift | Sampling position shift |
[in] | isFirstSample | If true , this is a very first sampling operation. A required initial setup will be run. |
[in] | suffix | Sampling operation suffix, e.g. ".rgb" to sample 3 values only |
Definition at line 150 of file operation.cpp.
|
protected |
Definition at line 174 of file operation.cpp.
|
protected |
Prepares the spatial filtering operation execution.
[in] | width | Input texture width in pixels |
[in] | height | Input texture height in pixels |
Definition at line 197 of file operation.cpp.
|
protected |
Applies an offset to the sampling position at runtime.
Only used if the uniform shift is enabled when writing out the header code.
[in,out] | program | The program |
[in] | shift | The shift in pixels |
[in] | inputSize | Size of the sampled input texture in pixels |
Definition at line 209 of file operation.cpp.
|
protected |
Prepares a given program for spatial filtering.
[in,out] | program | The program |
Definition at line 217 of file operation.cpp.
|
protected |
Implements common padding policies by computing a rectangular area of positions the sampling kernel takes in order to get the result with the required padding.
[in] | size | The input size in pixels |
[in] | stride | The stride |
[in] | padding | The padding policy |
Definition at line 223 of file operation.cpp.
|
protected |
Computes area in pixels to sample a given storage according to specific stride and padding.
[in] | storage | The input storage to sample |
[in] | channel | Number of the channel to sample |
[in] | stride | The stride |
[in] | padding | The padding policy |
Definition at line 253 of file operation.cpp.
|
protected |
Computes texture coordinates sampling a specific storage channel for given stride, padding and output size.
[in] | storage | The storage to sample |
[in] | channel | The channel number in the storage to sample |
[in] | stride | The stride |
[in] | padding | The padding |
[in] | outputSize | Size of output texture in pixels |
Definition at line 261 of file operation.cpp.
|
protected |
Retrieves input sampling point position for the current fragment.
Defined after declare() is called.
Definition at line 276 of file operation.cpp.
|
inlineprotected |
Definition at line 394 of file operation.h.
|
private |
Definition at line 274 of file operation.h.
|
private |
Definition at line 274 of file operation.h.
|
private |
current static shift of the sampling position
Definition at line 275 of file operation.h.
|
private |
array storing pixel position differences for neighborhood sampling
Definition at line 276 of file operation.h.
|
private |
if true
, the sampling position can be shifted dynamically at every run
Definition at line 277 of file operation.h.
|
staticprotected |
prefix of variables declaring a neighbor sample
Definition at line 285 of file operation.h.