Skip to content

Commit ef9a23e

Browse files
committed
More
1 parent d381e94 commit ef9a23e

File tree

17 files changed

+360
-164
lines changed

17 files changed

+360
-164
lines changed

bin/resources/shaders/dx11/convert.fx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#define PS_HDR 0
66
#endif
77

8+
#if PS_HDR
9+
//#define NEUTRAL_ALPHA 127.5f
10+
#define NEUTRAL_ALPHA 128.0f
11+
#else
12+
#define NEUTRAL_ALPHA 128.0f
13+
#endif
14+
815
struct VS_INPUT
916
{
1017
float4 p : POSITION;
@@ -147,6 +154,7 @@ PS_OUTPUT ps_datm1_rta_correction(PS_INPUT input)
147154
return output;
148155
}
149156

157+
//TODO: these in HDR?
150158
PS_OUTPUT ps_datm0_rta_correction(PS_INPUT input)
151159
{
152160
PS_OUTPUT output;
@@ -162,21 +170,29 @@ PS_OUTPUT ps_rta_correction(PS_INPUT input)
162170
{
163171
PS_OUTPUT output;
164172
float4 value = sample_c(input.t);
165-
#if 1 //TODO: saturate this and the above+below ones too? I was suggested to not to
173+
#if PS_HDR && 0 //TODO: saturate this and the above+below ones too? I was suggested to not to. Anyway this is not needed until proven otherwise.
166174
value.a = saturate(value.a);
167175
#endif
168-
output.c = float4(value.rgb, value.a * (255.0f / 128.25f));
176+
#if PS_HDR
177+
output.c = float4(value.rgb, value.a * (255.0f / NEUTRAL_ALPHA));
178+
#else
179+
output.c = float4(value.rgb, value.a * (255.0f / (NEUTRAL_ALPHA + 0.25f)));
180+
#endif
169181
return output;
170182
}
171183

172184
PS_OUTPUT ps_rta_decorrection(PS_INPUT input)
173185
{
174186
PS_OUTPUT output;
175187
float4 value = sample_c(input.t);
176-
#if 1
188+
#if PS_HDR && 0
177189
value.a = saturate(value.a);
178190
#endif
179-
output.c = float4(value.rgb, value.a * (128.25f / 255.0f));
191+
#if PS_HDR
192+
output.c = float4(value.rgb, value.a * (NEUTRAL_ALPHA / 255.0f));
193+
#else
194+
output.c = float4(value.rgb, value.a * ((NEUTRAL_ALPHA + 0.25f) / 255.0f));
195+
#endif
180196
return output;
181197
}
182198

@@ -477,6 +493,7 @@ PS_OUTPUT ps_yuv(PS_INPUT input)
477493
return output;
478494
}
479495

496+
//TODO: these in HDR?
480497
float ps_stencil_image_init_0(PS_INPUT input) : SV_Target
481498
{
482499
float c;
@@ -497,6 +514,7 @@ float ps_stencil_image_init_1(PS_INPUT input) : SV_Target
497514
return c;
498515
}
499516

517+
//TODO: these in HDR?
500518
float ps_stencil_image_init_2(PS_INPUT input)
501519
: SV_Target
502520
{

bin/resources/shaders/dx11/merge.fx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ struct PS_INPUT
2121
float4 ps_main0(PS_INPUT input) : SV_Target0
2222
{
2323
float4 c = Texture.Sample(Sampler, input.t);
24-
c.a *= 2.0f;
24+
// Alpha 0x80 (128) would be interpreted as 1 (neutral) here, but after it's multiplied by 2 and clamped to 0xFF
25+
c.a = saturate(c.a * 2.0f); //TODO: why? Explain it. Shouldn't this be 255/128 (1.9921875)? Especially if the source texture was RTAd?
2526
return c;
2627
}
2728

0 commit comments

Comments
 (0)