Reverted linear conversion on shader
Some checks failed
GenerateBuilds / generate-port-o2r (push) Has been cancelled
GenerateBuilds / build-windows (push) Has been cancelled
GenerateBuilds / build-macos (push) Has been cancelled
GenerateBuilds / build-linux (push) Has been cancelled
GenerateBuilds / build-switch (push) Has been cancelled

This commit is contained in:
KiritoDv 2025-04-17 11:07:37 -06:00
parent d75c912b87
commit c044335ef3

View file

@ -147,6 +147,17 @@ float random(float3 value) {
return fract(sin(random) * 143758.5453);
}
float4 fromLinear(float4 linearRGB) {
float3 threshold = float3(0.0031308);
float3 gamma = float3(1.0 / 2.4);
float3 scale = float3(12.92);
float3 offset = float3(1.055);
float3 subtract = float3(0.055);
float3 higher = offset * fast::pow(linearRGB.xyz, gamma) - subtract;
float3 lower = linearRGB.xyz * scale;
return float4(select(higher, lower, linearRGB.xyz < threshold), linearRGB.w);
}
fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUniforms &frameUniforms [[buffer(0)]]
@if(o_textures[0])
, texture2d<float> uTex0 [[texture(0)]], sampler uTex0Smplr [[sampler(0)]]
@ -277,8 +288,8 @@ fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUn
@if(o_invisible)
texel.w = 0.0;
@end
return texel;
return fromLinear(texel);
@else
return float4(texel, 1.0);
return fromLinear(float4(texel, 1.0));
@end
}