Skip to content

Commit

Permalink
Fix the sRGB issue.
Browse files Browse the repository at this point in the history
See:
#337
  • Loading branch information
andy840119 committed Apr 3, 2023
1 parent b53d2e2 commit de2bf76
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Font.Tests/Resources/Shaders/sh_CRT.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void main(void)

if (insideLens(lensUV))
{
vec4 lensCol = toSRGB(texture2D(m_Sampler, lensUV * resolution));
vec4 lensCol = texture2D(m_Sampler, lensUV * resolution);
lensCol = scanlines(lensCol, lensUV);
float smoothEdge = smoothLensEdge(lensUV);
col = vec4(lensCol.rgb * smoothEdge, clamp(lensCol.a + 1.0 - smoothEdge, 0.0, 1.0));
Expand Down
5 changes: 3 additions & 2 deletions osu.Framework.Font/Graphics/Shaders/OutlineShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Runtime.InteropServices;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Shaders.Types;
Expand All @@ -29,8 +30,8 @@ public override void ApplyValue(IRenderer renderer)

outlineParametersBuffer.Data = new OutlineParameters
{
Colour = new Vector4(Colour.R, Colour.G, Colour.B, Colour.A),
OutlineColour = new Vector4(OutlineColour.R, OutlineColour.G, OutlineColour.B, OutlineColour.A),
Colour = new Vector4(Colour.ToSRGB().R, Colour.ToSRGB().G, Colour.ToSRGB().B, Colour.ToSRGB().A),
OutlineColour = new Vector4(OutlineColour.ToSRGB().R, OutlineColour.ToSRGB().G, OutlineColour.ToSRGB().B, OutlineColour.ToSRGB().A),
Radius = Radius,
};

Expand Down
3 changes: 2 additions & 1 deletion osu.Framework.Font/Graphics/Shaders/ShadowShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Runtime.InteropServices;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Extensions;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Rendering;
Expand All @@ -28,7 +29,7 @@ public override void ApplyValue(IRenderer renderer)

shadowParametersBuffer.Data = new ShadowParameters
{
Colour = new Vector4(ShadowColour.R, ShadowColour.G, ShadowColour.B, ShadowColour.A),
Colour = new Vector4(ShadowColour.ToSRGB().R, ShadowColour.ToSRGB().G, ShadowColour.ToSRGB().B, ShadowColour.ToSRGB().A),
Offset = renderer.ToShaderVector2(ShadowOffset),
};

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Font/Resources/Shaders/sh_Outline.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ lowp vec4 outline(float radius, mediump vec2 texCoord, mediump vec2 texSize, med

void main(void)
{
lowp vec4 texColour = toSRGB(texture(sampler2D(m_Texture, m_Sampler), v_TexCoord));
lowp vec4 texColour = texture(sampler2D(m_Texture, m_Sampler), v_TexCoord);
lowp vec4 originColour = vec4(mix(texColour.rgb, g_Colour.rgb, g_Colour.a), texColour.a);
lowp vec4 outlineColour = outline(g_Radius * g_InflationPercentage, v_TexCoord, g_TexSize, g_OutlineColour);

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Font/Resources/Shaders/sh_Pixel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ void main(void)
uv = uv * separaorParts;
uv = floor(uv);
uv = uv / separaorParts;
o_Colour = toSRGB(texture(sampler2D(m_Texture, m_Sampler), uv));
o_Colour = texture(sampler2D(m_Texture, m_Sampler), uv);
}
2 changes: 1 addition & 1 deletion osu.Framework.Font/Resources/Shaders/sh_Rainbow.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ layout(location = 0) out vec4 o_Colour;
void main(void)
{
float pos = (v_TexCoord.y - g_Uv[0]) / (g_Uv[1] - g_Uv[0]);
vec4 texColor = toSRGB(texture(sampler2D(m_Texture, m_Sampler), v_TexCoord));
vec4 texColor = texture(sampler2D(m_Texture, m_Sampler), v_TexCoord);

vec4 col = vec4(g_Section * ((g_Time * g_Speed) + pos), g_Saturation, g_Brightness, 1);
vec4 finalCol = mix(texColor, vec4(hsv2rgb(col).xyz, texColor.a), g_Mix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ void main(void) {
// get point colour from sample.
vec4 texColor = texture(sampler2D(m_Texture, m_Sampler), v_TexCoord);
vec4 repeatSampleColor = v_Colour * vec4(texture(sampler2D(m_RepeatTexture, m_RepeatSampler), fixedTexCoord).xyz, texColor.a);
o_Colour = toSRGB(mix(texColor, repeatSampleColor, g_Mix));
o_Colour = mix(texColor, repeatSampleColor, g_Mix);
}
2 changes: 1 addition & 1 deletion osu.Framework.Font/Resources/Shaders/sh_Shadow.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lowp vec4 shadow(texture2D tex, mediump vec2 texCoord, mediump vec2 texSize, med

void main(void)
{
lowp vec4 texture = toSRGB(texture(sampler2D(m_Texture, m_Sampler), v_TexCoord));
lowp vec4 texture = texture(sampler2D(m_Texture, m_Sampler), v_TexCoord);
lowp vec4 shadow = shadow(m_Texture, v_TexCoord, g_TexSize, g_Colour, g_Offset * g_InflationPercentage);
o_Colour = mix(shadow, texture, texture.a);
}

0 comments on commit de2bf76

Please sign in to comment.