Skip to content

Commit

Permalink
fix: support 'Apply display rotation during rendering' for Vulkan (ex…
Browse files Browse the repository at this point in the history
…perimental)

close #171
  • Loading branch information
mob-sakai committed Jul 19, 2024
1 parent 15d6917 commit f5c9b41
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Packages/src/Shaders/SoftMask.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ float2 WorldToUv(float4 worldPos)
isSceneView);
}

float2 ClipToUv(float4 clipPos)
float2 ClipToUv(const float2 clipPos)
{
half2 uv = clipPos.xy / _ScreenParams.xy;
#if UNITY_UV_STARTS_AT_TOP
uv.y = lerp(uv.y, 1 - uv.y, step(0, _ProjectionParams.x));
if (0 < _ProjectionParams.x)
uv.y = 1 - uv.y;

#if UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION
float ratio = _ScreenParams.x / _ScreenParams.y;
switch (UNITY_DISPLAY_ORIENTATION_PRETRANSFORM)
{
case UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_90:
return half2((1 - uv.y) / ratio, uv.x * ratio);
case UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_180:
return half2(1 - uv.x, 1 - uv.y);
case UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_270:
return half2((uv.y + ratio - 1) / ratio, 1 - uv.x * ratio);
}
#endif

return uv;
Expand Down

0 comments on commit f5c9b41

Please sign in to comment.