-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support capturing rotated displays on Windows (#1602)
- Loading branch information
Showing
7 changed files
with
222 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 32 additions & 15 deletions
47
src_assets/windows/assets/shaders/directx/ConvertUVVS.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,46 @@ | ||
struct VertTexPosWide { | ||
float3 uuv : TEXCOORD; | ||
float4 pos : SV_POSITION; | ||
float3 uuv : TEXCOORD; | ||
float4 pos : SV_POSITION; | ||
}; | ||
|
||
cbuffer info : register(b0) { | ||
float width_i; | ||
float width_i; | ||
}; | ||
|
||
cbuffer rotation_info : register(b1) { | ||
int rotation; | ||
}; | ||
|
||
//-------------------------------------------------------------------------------------- | ||
// Vertex Shader | ||
//-------------------------------------------------------------------------------------- | ||
VertTexPosWide main_vs(uint vI : SV_VERTEXID) | ||
{ | ||
float idHigh = float(vI >> 1); | ||
float idLow = float(vI & uint(1)); | ||
VertTexPosWide output; | ||
float2 tex; | ||
|
||
if (vI == 0) { | ||
output.pos = float4(-1, -1, 0, 1); | ||
tex = float2(0, 1); | ||
} | ||
else if (vI == 1) { | ||
output.pos = float4(-1, 3, 0, 1); | ||
tex = float2(0, -1); | ||
} | ||
else if (vI == 2) { | ||
output.pos = float4(3, -1, 0, 1); | ||
tex = float2(2, 1); | ||
} | ||
|
||
float x = idHigh * 4.0 - 1.0; | ||
float y = idLow * 4.0 - 1.0; | ||
if (rotation != 0) { | ||
float rotation_radians = radians(90 * rotation); | ||
float2x2 rotation_matrix = { cos(rotation_radians), -sin(rotation_radians), | ||
sin(rotation_radians), cos(rotation_radians) }; | ||
float2 rotation_center = { 0.5, 0.5 }; | ||
tex = round(rotation_center + mul(rotation_matrix, tex - rotation_center)); | ||
} | ||
|
||
float u_right = idHigh * 2.0; | ||
float u_left = u_right - width_i; | ||
float v = 1.0 - idLow * 2.0; | ||
output.uuv = float3(tex.x, tex.x - width_i, tex.y); | ||
|
||
VertTexPosWide vert_out; | ||
vert_out.uuv = float3(u_left, u_right, v); | ||
vert_out.pos = float4(x, y, 0.0, 1.0); | ||
return vert_out; | ||
} | ||
return output; | ||
} |
Oops, something went wrong.