mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-26 09:21:30 +11:00
Moved scanline_size out to main shader for easier integration with HSM
This commit is contained in:
parent
55e0796400
commit
5e6351e2c7
|
@ -417,7 +417,8 @@ vec3 Hdr10Conditional(const vec3 scanline_colour)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 scanline_colour = GenerateScanline(global.SourceSize.xy);
|
const float scanline_size = global.OutputSize.y / global.SourceSize.y;
|
||||||
|
vec3 scanline_colour = GenerateScanline(global.SourceSize.xy, scanline_size);
|
||||||
|
|
||||||
const uint screen_type = uint(HCRT_CRT_SCREEN_TYPE);
|
const uint screen_type = uint(HCRT_CRT_SCREEN_TYPE);
|
||||||
const uint crt_resolution = uint(HCRT_CRT_RESOLUTION);
|
const uint crt_resolution = uint(HCRT_CRT_RESOLUTION);
|
||||||
|
|
|
@ -46,7 +46,7 @@ vec3 InverseTonemapConditional(const vec3 linear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 ScanlineColour(const vec2 source_size, const vec3 source_tex_coord_x, const vec3 narrowed_source_pixel_offset, inout vec3 next_prev)
|
vec3 ScanlineColour(const vec2 source_size, const float scanline_size, const vec3 source_tex_coord_x, const vec3 narrowed_source_pixel_offset, inout vec3 next_prev)
|
||||||
{
|
{
|
||||||
const vec3 current_source_position_y = (vec3(vTexCoord.y * source_size.y) - vec3(HCRT_RED_VERTICAL_CONVERGENCE, HCRT_GREEN_VERTICAL_CONVERGENCE, HCRT_BLUE_VERTICAL_CONVERGENCE)) + next_prev;
|
const vec3 current_source_position_y = (vec3(vTexCoord.y * source_size.y) - vec3(HCRT_RED_VERTICAL_CONVERGENCE, HCRT_GREEN_VERTICAL_CONVERGENCE, HCRT_BLUE_VERTICAL_CONVERGENCE)) + next_prev;
|
||||||
const vec3 current_source_center_y = floor(current_source_position_y) + 0.5f;
|
const vec3 current_source_center_y = floor(current_source_position_y) + 0.5f;
|
||||||
|
@ -55,8 +55,6 @@ vec3 ScanlineColour(const vec2 source_size, const vec3 source_tex_coord_x, const
|
||||||
|
|
||||||
const vec3 scanline_delta = fract(current_source_position_y) - 0.5f;
|
const vec3 scanline_delta = fract(current_source_position_y) - 0.5f;
|
||||||
|
|
||||||
const float scanline_size = global.OutputSize.y / source_size.y;
|
|
||||||
|
|
||||||
// Slightly increase the beam width to get maximum brightness
|
// Slightly increase the beam width to get maximum brightness
|
||||||
vec3 beam_distance = abs(scanline_delta - next_prev) - (kBeamWidth / scanline_size);
|
vec3 beam_distance = abs(scanline_delta - next_prev) - (kBeamWidth / scanline_size);
|
||||||
beam_distance = vec3(beam_distance.x < 0.0f ? 0.0f : beam_distance.x,
|
beam_distance = vec3(beam_distance.x < 0.0f ? 0.0f : beam_distance.x,
|
||||||
|
@ -115,7 +113,7 @@ vec3 ScanlineColour(const vec2 source_size, const vec3 source_tex_coord_x, const
|
||||||
return luminance * hdr_colour;
|
return luminance * hdr_colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 GenerateScanline(const vec2 source_size)
|
vec3 GenerateScanline(const vec2 source_size, const float scanline_size)
|
||||||
{
|
{
|
||||||
const vec3 current_source_position_x = vec3(vTexCoord.x * source_size.x) - vec3(HCRT_RED_HORIZONTAL_CONVERGENCE, HCRT_GREEN_HORIZONTAL_CONVERGENCE, HCRT_BLUE_HORIZONTAL_CONVERGENCE);
|
const vec3 current_source_position_x = vec3(vTexCoord.x * source_size.x) - vec3(HCRT_RED_HORIZONTAL_CONVERGENCE, HCRT_GREEN_HORIZONTAL_CONVERGENCE, HCRT_BLUE_HORIZONTAL_CONVERGENCE);
|
||||||
const vec3 current_source_center_x = floor(current_source_position_x) + 0.5f;
|
const vec3 current_source_center_x = floor(current_source_position_x) + 0.5f;
|
||||||
|
@ -129,13 +127,13 @@ vec3 GenerateScanline(const vec2 source_size)
|
||||||
|
|
||||||
vec3 next_prev = vec3(0.0f);
|
vec3 next_prev = vec3(0.0f);
|
||||||
|
|
||||||
const vec3 scanline_colour0 = ScanlineColour(source_size, source_tex_coord_x, narrowed_source_pixel_offset, next_prev);
|
const vec3 scanline_colour0 = ScanlineColour(source_size, scanline_size, source_tex_coord_x, narrowed_source_pixel_offset, next_prev);
|
||||||
|
|
||||||
// Optionally sample the neighbouring scanline
|
// Optionally sample the neighbouring scanline
|
||||||
vec3 scanline_colour1 = vec3(0.0f);
|
vec3 scanline_colour1 = vec3(0.0f);
|
||||||
if(HCRT_RED_SCANLINE_MAX > 1.0f || HCRT_GREEN_SCANLINE_MAX > 1.0f || HCRT_BLUE_SCANLINE_MAX > 1.0f)
|
if(HCRT_RED_SCANLINE_MAX > 1.0f || HCRT_GREEN_SCANLINE_MAX > 1.0f || HCRT_BLUE_SCANLINE_MAX > 1.0f)
|
||||||
{
|
{
|
||||||
scanline_colour1 = ScanlineColour(source_size, source_tex_coord_x, narrowed_source_pixel_offset, next_prev);
|
scanline_colour1 = ScanlineColour(source_size, scanline_size, source_tex_coord_x, narrowed_source_pixel_offset, next_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return scanline_colour0 + scanline_colour1;
|
return scanline_colour0 + scanline_colour1;
|
||||||
|
|
Loading…
Reference in a new issue