mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-07-20 22:32:01 +00:00
Request true floating-point EGL configs for scRGB and expose the native encodings supported by the selected surface. Fall back to software HDR mapping when the surface cannot represent the incoming wire format. Resample PQ in linear light, keep SDR-only effects out of native PQ chains, and consume the cursor-specific white level without changing binary monochrome cursor mask operations.
43 lines
829 B
GLSL
43 lines
829 B
GLSL
#version 300 es
|
|
precision highp float;
|
|
precision highp int;
|
|
|
|
#include "hdr.h"
|
|
|
|
in vec2 uv;
|
|
out vec4 color;
|
|
|
|
uniform sampler2D sampler1;
|
|
uniform float scale;
|
|
uniform int wireTransfer; // 0: sRGB, 1: scRGB, 2: PQ
|
|
uniform float sdrWhiteLevel;
|
|
|
|
void main()
|
|
{
|
|
vec4 tmp;
|
|
if (scale > 1.0)
|
|
{
|
|
vec2 ts = vec2(textureSize(sampler1, 0));
|
|
vec2 px = (uv - (0.5 / ts)) * ts;
|
|
if (px.x < 0.0 || px.y < 0.0)
|
|
discard;
|
|
|
|
tmp = texelFetch(sampler1, ivec2(px), 0);
|
|
}
|
|
else
|
|
tmp = texture(sampler1, uv);
|
|
|
|
if (tmp.rgb == vec3(0.0, 0.0, 0.0))
|
|
discard;
|
|
|
|
if (wireTransfer == 2)
|
|
{
|
|
vec3 linear = bt709to2020(srgb2lin(tmp.rgb));
|
|
tmp.rgb = lin2pq(linear * (sdrWhiteLevel / 10000.0));
|
|
}
|
|
else if (wireTransfer == 1)
|
|
tmp.rgb = srgb2lin(tmp.rgb) * (sdrWhiteLevel / 80.0);
|
|
|
|
color = tmp;
|
|
}
|