summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/shared/imgui/imgui.frag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/rhi/shared/imgui/imgui.frag')
-rw-r--r--tests/manual/rhi/shared/imgui/imgui.frag37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/manual/rhi/shared/imgui/imgui.frag b/tests/manual/rhi/shared/imgui/imgui.frag
new file mode 100644
index 0000000000..6169dd639f
--- /dev/null
+++ b/tests/manual/rhi/shared/imgui/imgui.frag
@@ -0,0 +1,37 @@
+#version 440
+
+layout(location = 0) in vec2 v_texcoord;
+layout(location = 1) in vec4 v_color;
+
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+ float opacity;
+ // Windows HDR: set to SDR_white_level_in_nits / 80
+ // macOS/iOS EDR: set to 1.0
+ // No HDR: set to 0.0, will do linear to sRGB at the end then.
+ float hdrWhiteLevelMult;
+};
+
+layout(binding = 1) uniform sampler2D tex;
+
+vec3 linearToSRGB(vec3 color)
+{
+ vec3 S1 = sqrt(color);
+ vec3 S2 = sqrt(S1);
+ vec3 S3 = sqrt(S2);
+ return 0.585122381 * S1 + 0.783140355 * S2 - 0.368262736 * S3;
+}
+
+void main()
+{
+ vec4 c = v_color * texture(tex, v_texcoord);
+ c.a *= opacity;
+ if (hdrWhiteLevelMult > 0.0)
+ c.rgb *= hdrWhiteLevelMult;
+ else
+ c.rgb = linearToSRGB(c.rgb);
+ c.rgb *= c.a; // premultiplied alpha
+ fragColor = c;
+}