Skip to content

Commit

Permalink
fix bug that caused darker screen #22.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Aug 4, 2018
1 parent c926127 commit 70cfad9
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Assets/uDesktopDuplication/Scripts/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ void Awake()
Lib.Initialize();

CreateMonitors();

#if UNITY_2018_1_OR_NEWER
Shader.DisableKeyword("USE_GAMMA_TO_LINEAR_SPACE");
#else
Shader.EnableKeyword("USE_GAMMA_TO_LINEAR_SPACE");
#endif
}

void OnApplicationQuit()
Expand Down
5 changes: 4 additions & 1 deletion Assets/uDesktopDuplication/Scripts/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,16 @@ void Reinitialize()
monitor = Manager.GetMonitor(lastMonitorId_);
}

int clipPositionScaleKey_ = Shader.PropertyToID("_ClipPositionScale");
void UpdateMaterial()
{
width = transform.localScale.x;

if (monitor != null) {
rotation = monitor.rotation;
}
material.SetVector("_ClipPositionScale", new Vector4(clipPos.x, clipPos.y, clipScale.x, clipScale.y));

material.SetVector(clipPositionScaleKey_, new Vector4(clipPos.x, clipPos.y, clipScale.x, clipScale.y));
}

public Vector3 GetWorldPositionFromCoord(Vector2 coord)
Expand Down
2 changes: 2 additions & 0 deletions Assets/uDesktopDuplication/Shaders/uDD_Common.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ inline float2 uddClipUV(float2 uv)

inline void uddConvertToLinearIfNeeded(inout fixed3 rgb)
{
#ifdef USE_GAMMA_TO_LINEAR_SPACE
if (!IsGammaSpace()) {
rgb = GammaToLinearSpace(rgb);
}
#endif
}

inline fixed4 uddGetTexture(sampler2D tex, float2 uv)
Expand Down
1 change: 1 addition & 0 deletions Assets/uDesktopDuplication/Shaders/uDD_Standard.shader
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SubShader
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#pragma multi_compile ___ USE_GAMMA_TO_LINEAR_SPACE

#define SURFACE_SHADER
#include "./uDD_Common.cginc"
Expand Down
1 change: 1 addition & 0 deletions Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Pass
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#pragma multi_compile ___ USE_GAMMA_TO_LINEAR_SPACE
ENDCG
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Pass
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#pragma multi_compile ___ USE_GAMMA_TO_LINEAR_SPACE
ENDCG
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Pass
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#pragma multi_compile ___ USE_GAMMA_TO_LINEAR_SPACE
ENDCG
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Pass
#pragma multi_compile ___ USE_CLIP
#pragma multi_compile ___ BEND_ON
#pragma multi_compile _FORWARD_Y _FORWARD_Z
#pragma multi_compile ___ USE_GAMMA_TO_LINEAR_SPACE
ENDCG
}

Expand Down

0 comments on commit 70cfad9

Please sign in to comment.