mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-12 15:31:09 +00:00
Returns gamma correction, and corrects Amstrad CPC brightness.
This commit is contained in:
parent
55290f4dad
commit
6c49953115
@ -178,6 +178,8 @@ class CRTCBusHandler {
|
|||||||
establish_palette_hits();
|
establish_palette_hits();
|
||||||
build_mode_table();
|
build_mode_table();
|
||||||
crt_.set_visible_area(Outputs::Display::Rect(0.1072f, 0.1f, 0.842105263157895f, 0.842105263157895f));
|
crt_.set_visible_area(Outputs::Display::Rect(0.1072f, 0.1f, 0.842105263157895f, 0.842105263157895f));
|
||||||
|
crt_.set_brightness(3.0f / 2.0f); // As only the values 0, 1 and 2 will be used in each channel,
|
||||||
|
// whereas Red2Green2Blue2 defines a range of 0-3.
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -98,6 +98,11 @@ void CRT::set_input_data_type(Outputs::Display::InputDataType input_data_type) {
|
|||||||
scan_target_->set_modals(scan_target_modals_);
|
scan_target_->set_modals(scan_target_modals_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRT::set_brightness(float brightness) {
|
||||||
|
scan_target_modals_.brightness = brightness;
|
||||||
|
scan_target_->set_modals(scan_target_modals_);
|
||||||
|
}
|
||||||
|
|
||||||
void CRT::set_new_display_type(int cycles_per_line, Outputs::Display::Type displayType) {
|
void CRT::set_new_display_type(int cycles_per_line, Outputs::Display::Type displayType) {
|
||||||
switch(displayType) {
|
switch(displayType) {
|
||||||
case Outputs::Display::Type::PAL50:
|
case Outputs::Display::Type::PAL50:
|
||||||
|
@ -273,6 +273,9 @@ class CRT {
|
|||||||
|
|
||||||
/*! Sets the input data type. */
|
/*! Sets the input data type. */
|
||||||
void set_input_data_type(Outputs::Display::InputDataType);
|
void set_input_data_type(Outputs::Display::InputDataType);
|
||||||
|
|
||||||
|
/*! Sets the output brightness. */
|
||||||
|
void set_brightness(float);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -285,8 +285,8 @@ void ScanTarget::setup_pipeline() {
|
|||||||
// lose any detail when combining the input.
|
// lose any detail when combining the input.
|
||||||
processing_width_ = modals_.cycles_per_line / modals_.clocks_per_pixel_greatest_common_divisor;
|
processing_width_ = modals_.cycles_per_line / modals_.clocks_per_pixel_greatest_common_divisor;
|
||||||
|
|
||||||
// Establish an output shader. TODO: add proper decoding and gamma correction here.
|
// Establish an output shader. TODO: don't hard-code gamma.
|
||||||
output_shader_ = conversion_shader(modals_.input_data_type, modals_.display_type, modals_.composite_colour_space);
|
output_shader_ = conversion_shader(modals_.input_data_type, modals_.display_type, modals_.composite_colour_space, 2.2f / modals_.intended_gamma, modals_.brightness);
|
||||||
glBindVertexArray(line_vertex_array_);
|
glBindVertexArray(line_vertex_array_);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_);
|
glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_);
|
||||||
enable_vertex_attributes(ShaderType::Conversion, *output_shader_);
|
enable_vertex_attributes(ShaderType::Conversion, *output_shader_);
|
||||||
|
@ -181,7 +181,7 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
|||||||
Produces a shader that reads from a composition buffer and converts to host
|
Produces a shader that reads from a composition buffer and converts to host
|
||||||
output RGB, decoding composite or S-Video as necessary.
|
output RGB, decoding composite or S-Video as necessary.
|
||||||
*/
|
*/
|
||||||
static std::unique_ptr<Shader> conversion_shader(InputDataType input_data_type, DisplayType display_type, ColourSpace colour_space);
|
static std::unique_ptr<Shader> conversion_shader(InputDataType input_data_type, DisplayType display_type, ColourSpace colour_space, float gamma_ratio, float brightness);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ std::unique_ptr<Shader> ScanTarget::composition_shader(InputDataType input_data_
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Shader> ScanTarget::conversion_shader(InputDataType input_data_type, DisplayType display_type, ColourSpace colour_space) {
|
std::unique_ptr<Shader> ScanTarget::conversion_shader(InputDataType input_data_type, DisplayType display_type, ColourSpace colour_space, float gamma_ratio, float brightness) {
|
||||||
// Compose a vertex shader. If the display type is RGB, generate just the proper
|
// Compose a vertex shader. If the display type is RGB, generate just the proper
|
||||||
// geometry position, plus a solitary textureCoordinate.
|
// geometry position, plus a solitary textureCoordinate.
|
||||||
//
|
//
|
||||||
@ -451,7 +451,16 @@ std::unique_ptr<Shader> ScanTarget::conversion_shader(InputDataType input_data_t
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO gamma and range corrections.
|
// Apply a brightness adjustment if requested.
|
||||||
|
if(fabs(brightness - 1.0f) > 0.05f) {
|
||||||
|
fragment_shader += "fragColour3 = fragColour3 * " + std::to_string(brightness) + ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply a gamma correction if required.
|
||||||
|
if(fabs(gamma_ratio - 1.0f) > 0.05f) {
|
||||||
|
fragment_shader += "fragColour3 = pow(fragColour3, vec3(" + std::to_string(gamma_ratio) + "));";
|
||||||
|
}
|
||||||
|
|
||||||
fragment_shader +=
|
fragment_shader +=
|
||||||
"fragColour = vec4(fragColour3, 0.64);"
|
"fragColour = vec4(fragColour3, 0.64);"
|
||||||
"}";
|
"}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user