2016-04-29 01:04:59 +00:00
|
|
|
//
|
|
|
|
// IntermediateShader.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 28/04/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef IntermediateShader_hpp
|
|
|
|
#define IntermediateShader_hpp
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "Shader.hpp"
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace OpenGL {
|
|
|
|
|
|
|
|
class IntermediateShader: public Shader {
|
|
|
|
public:
|
|
|
|
using Shader::Shader;
|
|
|
|
|
2016-04-29 01:55:14 +00:00
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will take runs from the inputPositions,
|
|
|
|
converting them to single-channel composite values using @c composite_shader if supplied
|
|
|
|
or @c rgb_shader and a reference composite conversion if @c composite_shader is @c nullptr.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
static std::unique_ptr<IntermediateShader> make_source_conversion_shader(const char *composite_shader, const char *rgb_shader);
|
2016-04-29 01:55:14 +00:00
|
|
|
|
2016-05-03 01:05:58 +00:00
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will take runs from the inputPositions,
|
|
|
|
converting them to RGB values using @c rgb_shader.
|
|
|
|
*/
|
|
|
|
static std::unique_ptr<IntermediateShader> make_rgb_source_shader(const char *rgb_shader);
|
|
|
|
|
2016-04-29 01:55:14 +00:00
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will read composite samples from the R channel,
|
|
|
|
filter then to obtain luminance, stored to R, and to separate out unfiltered chrominance, store to G and B.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
static std::unique_ptr<IntermediateShader> make_chroma_luma_separation_shader();
|
2016-04-29 01:55:14 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will pass R through unchanged while filtering G and B.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
static std::unique_ptr<IntermediateShader> make_chroma_filter_shader();
|
|
|
|
|
2016-05-03 11:46:40 +00:00
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will filter R while passing through G and B unchanged.
|
|
|
|
*/
|
|
|
|
static std::unique_ptr<IntermediateShader> make_luma_filter_shader();
|
|
|
|
|
2016-05-03 01:05:58 +00:00
|
|
|
/*!
|
|
|
|
Constructs and returns an intermediate shader that will filter R, G and B.
|
|
|
|
*/
|
|
|
|
static std::unique_ptr<IntermediateShader> make_rgb_filter_shader();
|
|
|
|
|
2016-04-29 01:04:59 +00:00
|
|
|
/*!
|
2016-04-29 01:45:44 +00:00
|
|
|
Binds this shader and configures it for output to an area of `output_width` and `output_height` pixels.
|
2016-04-29 01:04:59 +00:00
|
|
|
*/
|
|
|
|
void set_output_size(unsigned int output_width, unsigned int output_height);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Binds this shader and sets the texture unit (as an enum, e.g. `GL_TEXTURE0`) to sample as source data.
|
|
|
|
*/
|
|
|
|
void set_source_texture_unit(GLenum unit);
|
|
|
|
|
2016-04-29 01:45:44 +00:00
|
|
|
/*!
|
|
|
|
Binds this shader and sets filtering coefficients for a lowpass filter based on the cutoff.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
void set_filter_coefficients(float sampling_rate, float cutoff_frequency);
|
|
|
|
|
2016-05-03 01:05:58 +00:00
|
|
|
/*!
|
|
|
|
Binds this shader and configures filtering to separate luminance and chrominance based on a colour
|
|
|
|
subcarrier of the given frequency.
|
|
|
|
*/
|
|
|
|
void set_separation_frequency(float sampling_rate, float colour_burst_frequency);
|
|
|
|
|
2016-04-29 01:45:44 +00:00
|
|
|
/*!
|
|
|
|
Binds this shader and sets the number of colour phase cycles per sample, indicating whether output
|
|
|
|
geometry should be extended so that a complete colour cycle is included at both the beginning and end.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
void set_phase_cycles_per_sample(float phase_cycles_per_sample, bool extend_runs_to_full_cycle);
|
|
|
|
|
2016-04-29 01:45:44 +00:00
|
|
|
/*!
|
|
|
|
Binds this shader and sets the matrices that convert between RGB and chrominance/luminance.
|
|
|
|
*/
|
2016-04-29 01:04:59 +00:00
|
|
|
void set_colour_conversion_matrices(float *fromRGB, float *toRGB);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static std::unique_ptr<IntermediateShader> make_shader(const char *fragment_shader, bool use_usampler, bool input_is_inputPosition);
|
|
|
|
|
|
|
|
GLint texIDUniform;
|
|
|
|
GLint outputTextureSizeUniform;
|
|
|
|
GLint weightsUniform;
|
|
|
|
GLint phaseCyclesPerTickUniform;
|
|
|
|
GLint extensionUniform;
|
|
|
|
GLint rgbToLumaChromaUniform;
|
|
|
|
GLint lumaChromaToRGBUniform;
|
2016-04-29 22:37:35 +00:00
|
|
|
GLint offsetsUniform;
|
2016-04-29 01:04:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* IntermediateShader_hpp */
|