Skip to content

Commit 3ec16a4

Browse files
author
mai
committed
Merge branch 'experimental' of https://github.com/JackD83/ALVR into experimental
2 parents 28f7edd + f5184fe commit 3ec16a4

6 files changed

+112
-6
lines changed

ALVR/ServerConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ServerConfig
1717
private static readonly string APP_FILEMAPPING_NAME = "ALVR_DRIVER_FILEMAPPING_0B124897-7730-4B84-AA32-088E9B92851F";
1818

1919
public static readonly int DEFAULT_SCALE_INDEX = 3; // 100%
20-
public static readonly int[] supportedScales = { 25, 50, 75, 100, 125, 150, 175, 200 };
20+
public static readonly int[] supportedScales = { 25, 50, 66, 75, 100, 125, 150, 175, 200 };
2121

2222
public static readonly int DEFAULT_REFRESHRATE = 72;
2323
public static readonly int DEFAULT_WIDTH = 2432;

alvr_server/VideoEncoderVCE.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ AMFTextureEncoder::AMFTextureEncoder(const amf::AMFContextPtr &amfContext
4545
m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_FRAMESIZE, ::AMFConstructSize(width, height));
4646
m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_FRAMERATE, ::AMFConstructRate(frameRateIn, 1));
4747

48-
//m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PROFILE, AMF_VIDEO_ENCODER_PROFILE_HIGH);
49-
//m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PROFILE_LEVEL, 51);
48+
m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PROFILE, AMF_VIDEO_ENCODER_PROFILE_HIGH);
49+
m_amfEncoder->SetProperty(AMF_VIDEO_ENCODER_PROFILE_LEVEL, 51);
5050
}
5151
else
5252
{

alvr_server/driver_virtual_display.vcxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<PostBuildEvent>
7070
<Command>xcopy "$(TargetPath)" "$(SolutionDir)driver\bin\win64\" /Y</Command>
7171
</PostBuildEvent>
72+
<FxCompile>
73+
<TreatWarningAsError>true</TreatWarningAsError>
74+
</FxCompile>
7275
</ItemDefinitionGroup>
7376
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7477
<ClCompile>
@@ -95,6 +98,9 @@
9598
<PostBuildEvent>
9699
<Command>xcopy "$(TargetPath)" "$(SolutionDir)driver\bin\win64\" /Y</Command>
97100
</PostBuildEvent>
101+
<FxCompile>
102+
<TreatWarningAsError>true</TreatWarningAsError>
103+
</FxCompile>
98104
</ItemDefinitionGroup>
99105
<ItemGroup>
100106
<ClCompile Include="..\ALVR-common\common-utils.cpp" />
@@ -177,6 +183,7 @@
177183
</ItemGroup>
178184
<ItemGroup>
179185
<None Include="packages.config" />
186+
<None Include="shader\color.hlsli" />
180187
<None Include="shader\FoveatedRendering.hlsli" />
181188
</ItemGroup>
182189
<ItemGroup>

alvr_server/shader/ColorCorrectionPixelShader.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ float4 main(float2 uv : TEXCOORD0) : SV_Target{
3939
pixel += GetSharpenNeighborComponent(uv, -DX, +DY);
4040
pixel += GetSharpenNeighborComponent(uv, -DX, 0);
4141

42-
pixel = pow(pixel, 1. / gamma); // gamma
4342
pixel += brightness; // brightness
4443
pixel = (pixel - 0.5) * contrast + 0.5f; // contast
4544
pixel = lerp(dot(pixel, float3(0.299, 0.587, 0.114)), pixel, saturation); // saturation
4645

46+
pixel = clamp(pixel, 0, 1);
47+
pixel = pow(pixel, 1. / gamma); // gamma
48+
4749
return float4(pixel, 1);
4850
}

alvr_server/shader/FrameRender.fx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "color.hlsli"
2+
13
Texture2D txLeft : register(t0);
24
Texture2D txRight : register(t1);
35
SamplerState samLinear : register(s0);
@@ -26,10 +28,15 @@ PS_INPUT VS(VS_INPUT input)
2628
}
2729
float4 PS(PS_INPUT input) : SV_Target
2830
{
31+
float4 output;
2932
if (input.View == (uint)0) { // Left View
30-
return txLeft.Sample(samLinear, input.Tex);
33+
output = txLeft.Sample(samLinear, input.Tex);
34+
output.rgb = Rec709ToRec2020(output.rgb);
35+
return output;
3136
}
3237
else { // Right View
33-
return txRight.Sample(samLinear, input.Tex);
38+
output = txRight.Sample(samLinear, input.Tex);
39+
output.rgb = Rec709ToRec2020(output.rgb);
40+
return output;
3441
}
3542
};

alvr_server/shader/color.hlsli

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//*********************************************************
2+
//
3+
// Copyright (c) Microsoft. All rights reserved.
4+
// This code is licensed under the MIT License (MIT).
5+
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6+
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7+
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8+
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9+
//
10+
//*********************************************************
11+
12+
// These values must match the DisplayCurve enum in D3D12HDR.h.
13+
#define DISPLAY_CURVE_SRGB 0
14+
#define DISPLAY_CURVE_ST2084 1
15+
#define DISPLAY_CURVE_LINEAR 2
16+
17+
float3 xyYToRec709(float2 xy, float Y = 1.0)
18+
{
19+
// https://github.com/ampas/aces-dev/blob/v1.0.3/transforms/ctl/README-MATRIX.md
20+
static const float3x3 XYZtoRGB =
21+
{
22+
3.2409699419, -1.5373831776, -0.4986107603,
23+
-0.9692436363, 1.8759675015, 0.0415550574,
24+
0.0556300797, -0.2039769589, 1.0569715142
25+
};
26+
float3 XYZ = Y * float3(xy.x / xy.y, 1.0, (1.0 - xy.x - xy.y) / xy.y);
27+
float3 RGB = mul(XYZtoRGB, XYZ);
28+
float maxChannel = max(RGB.r, max(RGB.g, RGB.b));
29+
return RGB / max(maxChannel, 1.0);
30+
}
31+
32+
float3 xyYToRec2020(float2 xy, float Y = 1.0)
33+
{
34+
// https://github.com/ampas/aces-dev/blob/v1.0.3/transforms/ctl/README-MATRIX.md
35+
static const float3x3 XYZtoRGB =
36+
{
37+
1.7166511880, -0.3556707838, -0.2533662814,
38+
-0.6666843518, 1.6164812366, 0.0157685458,
39+
0.0176398574, -0.0427706133, 0.9421031212
40+
};
41+
float3 XYZ = Y * float3(xy.x / xy.y, 1.0, (1.0 - xy.x - xy.y) / xy.y);
42+
float3 RGB = mul(XYZtoRGB, XYZ);
43+
float maxChannel = max(RGB.r, max(RGB.g, RGB.b));
44+
return RGB / max(maxChannel, 1.0);
45+
}
46+
47+
float3 LinearToSRGB(float3 color)
48+
{
49+
// Approximately pow(color, 1.0 / 2.2)
50+
return color < 0.0031308 ? 12.92 * color : 1.055 * pow(abs(color), 1.0 / 2.4) - 0.055;
51+
}
52+
53+
float3 SRGBToLinear(float3 color)
54+
{
55+
// Approximately pow(color, 2.2)
56+
return color < 0.04045 ? color / 12.92 : pow(abs(color + 0.055) / 1.055, 2.4);
57+
}
58+
59+
float3 Rec709ToRec2020(float3 color)
60+
{
61+
static const float3x3 conversion =
62+
{
63+
0.627402, 0.329292, 0.043306,
64+
0.069095, 0.919544, 0.011360,
65+
0.016394, 0.088028, 0.895578
66+
};
67+
return mul(conversion, color);
68+
}
69+
70+
float3 Rec2020ToRec709(float3 color)
71+
{
72+
static const float3x3 conversion =
73+
{
74+
1.660496, -0.587656, -0.072840,
75+
-0.124547, 1.132895, -0.008348,
76+
-0.018154, -0.100597, 1.118751
77+
};
78+
return mul(conversion, color);
79+
}
80+
81+
float3 LinearToST2084(float3 color)
82+
{
83+
float m1 = 2610.0 / 4096.0 / 4;
84+
float m2 = 2523.0 / 4096.0 * 128;
85+
float c1 = 3424.0 / 4096.0;
86+
float c2 = 2413.0 / 4096.0 * 32;
87+
float c3 = 2392.0 / 4096.0 * 32;
88+
float3 cp = pow(abs(color), m1);
89+
return pow((c1 + c2 * cp) / (1 + c3 * cp), m2);
90+
}

0 commit comments

Comments
 (0)