Files
Xenia-Canary/src/xenia/gpu/d3d12/shaders/stretch_gamma.ps.hlsl
2018-10-03 14:36:17 +03:00

20 lines
886 B
HLSL

Texture2D<float4> xe_texture : register(t0);
Texture1D<float3> xe_gamma_ramp : register(t1);
SamplerState xe_sampler_linear_clamp : register(s0);
cbuffer XeStretchGammaRootConstants : register(b0) {
float xe_gamma_ramp_inv_size;
};
float4 main(float2 xe_texcoord : TEXCOORD) : SV_Target {
float4 color =
xe_texture.SampleLevel(xe_sampler_linear_clamp, xe_texcoord, 0.0f);
// The center of the first texel of the LUT contains the value for 0, and the
// center of the last texel contains the value for 1.
color.rgb = color.rgb * (1.0f - xe_gamma_ramp_inv_size) +
(0.5 * xe_gamma_ramp_inv_size);
color.r = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.r, 0.0f).r;
color.g = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.g, 0.0f).g;
color.b = xe_gamma_ramp.SampleLevel(xe_sampler_linear_clamp, color.b, 0.0f).b;
return color;
}