add thickness control.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MeshForwardDirection = uDesktopDuplication.Texture.MeshForwardDirection;
|
||||||
|
|
||||||
public class MultipleMonitorCreator : MonoBehaviour
|
public class MultipleMonitorCreator : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -9,8 +10,7 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
bool hasMonitorUnsupportStateChecked = false;
|
bool hasMonitorUnsupportStateChecked = false;
|
||||||
float removeWaitTimer_ = 0f;
|
float removeWaitTimer_ = 0f;
|
||||||
|
|
||||||
public enum MeshForwardDirection { Y, Z }
|
[Tooltip("Please specify the surface direction of the mesh (e.g. Plane => Y.)")]
|
||||||
[Tooltip("Please specify the upper vector direction of the mesh (e.g. Plane's upper direction is Y.)")]
|
|
||||||
public MeshForwardDirection meshForwardDirection = MeshForwardDirection.Z;
|
public MeshForwardDirection meshForwardDirection = MeshForwardDirection.Z;
|
||||||
|
|
||||||
public class MonitorInfo
|
public class MonitorInfo
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ public class MultipleMonitorLayouter : MonoBehaviour
|
|||||||
protected MultipleMonitorCreator creator_;
|
protected MultipleMonitorCreator creator_;
|
||||||
[SerializeField] bool updateEveryFrame = true;
|
[SerializeField] bool updateEveryFrame = true;
|
||||||
[SerializeField] protected float margin = 0.1f;
|
[SerializeField] protected float margin = 0.1f;
|
||||||
|
[SerializeField][Range(0f, 10f)] protected float thickness = 1f;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -15,16 +16,13 @@ public class MultipleMonitorLayouter : MonoBehaviour
|
|||||||
|
|
||||||
protected virtual void Update()
|
protected virtual void Update()
|
||||||
{
|
{
|
||||||
|
margin = Mathf.Max(margin, 0f);
|
||||||
|
|
||||||
if (updateEveryFrame) {
|
if (updateEveryFrame) {
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LateUpdate()
|
|
||||||
{
|
|
||||||
margin = Mathf.Max(margin, 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Layout()
|
protected virtual void Layout()
|
||||||
{
|
{
|
||||||
var monitors = creator_.monitors;
|
var monitors = creator_.monitors;
|
||||||
@@ -39,13 +37,17 @@ public class MultipleMonitorLayouter : MonoBehaviour
|
|||||||
|
|
||||||
var x = -totalWidth / 2;
|
var x = -totalWidth / 2;
|
||||||
|
|
||||||
foreach (var info in creator_.monitors) {
|
foreach (var info in monitors) {
|
||||||
var monitor = info.uddTexture.monitor;
|
var monitor = info.uddTexture.monitor;
|
||||||
x += (monitor.widthMeter * info.mesh.bounds.extents.x);
|
x += (monitor.widthMeter * info.mesh.bounds.extents.x);
|
||||||
info.gameObject.transform.localPosition = new Vector3(x, 0f, 0f);
|
info.gameObject.transform.localPosition = new Vector3(x, 0f, 0f);
|
||||||
info.gameObject.transform.localRotation = info.originalRotation;
|
info.gameObject.transform.localRotation = info.originalRotation;
|
||||||
x += (monitor.widthMeter * info.mesh.bounds.extents.x) + margin;
|
x += (monitor.widthMeter * info.mesh.bounds.extents.x) + margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var info in monitors) {
|
||||||
|
info.uddTexture.thickness = thickness;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
||||||
{
|
{
|
||||||
[SerializeField] float radius = 10f;
|
[SerializeField] float radius = 10f;
|
||||||
[SerializeField] float offsetAngle = 0f;
|
[SerializeField][Range(-180f, 180f)] float offsetAngle = 0f;
|
||||||
|
|
||||||
void OnDisable()
|
void OnDisable()
|
||||||
{
|
{
|
||||||
foreach (var info in creator_.monitors) {
|
foreach (var info in creator_.monitors) {
|
||||||
info.uddTexture.bend = uDesktopDuplication.Texture.Bend.Off;
|
info.uddTexture.bend = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,12 +37,10 @@ public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
|||||||
uddTex.transform.localRotation = Quaternion.AngleAxis(angle * Mathf.Rad2Deg, Vector3.up) * info.originalRotation;
|
uddTex.transform.localRotation = Quaternion.AngleAxis(angle * Mathf.Rad2Deg, Vector3.up) * info.originalRotation;
|
||||||
angle += (width * 0.5f + margin) / radius;
|
angle += (width * 0.5f + margin) / radius;
|
||||||
|
|
||||||
if (creator_.meshForwardDirection == MultipleMonitorCreator.MeshForwardDirection.Y) {
|
uddTex.bend = true;
|
||||||
uddTex.bend = uDesktopDuplication.Texture.Bend.Y;
|
uddTex.meshForwardDirection = creator_.meshForwardDirection;
|
||||||
} else {
|
|
||||||
uddTex.bend = uDesktopDuplication.Texture.Bend.Z;
|
|
||||||
}
|
|
||||||
uddTex.radius = radius;
|
uddTex.radius = radius;
|
||||||
|
uddTex.thickness = thickness;
|
||||||
uddTex.width = uddTex.transform.localScale.x;
|
uddTex.width = uddTex.transform.localScale.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,37 +34,44 @@ public class Texture : MonoBehaviour
|
|||||||
public Vector2 clipPos = Vector2.zero;
|
public Vector2 clipPos = Vector2.zero;
|
||||||
public Vector2 clipScale = new Vector2(0.2f, 0.2f);
|
public Vector2 clipScale = new Vector2(0.2f, 0.2f);
|
||||||
|
|
||||||
public enum Bend
|
public enum MeshForwardDirection
|
||||||
{
|
{
|
||||||
Off = 0,
|
Y = 0,
|
||||||
Y = 1,
|
Z = 1,
|
||||||
Z = 2,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bend bend
|
public bool bend
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (Bend)material.GetInt("_Bend");
|
return material.GetInt("_Bend") != 0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value) {
|
||||||
|
material.EnableKeyword("BEND_ON");
|
||||||
|
} else {
|
||||||
|
material.DisableKeyword("BEND_ON");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MeshForwardDirection meshForwardDirection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (MeshForwardDirection)material.GetInt("_Forward");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case Bend.Off:
|
case MeshForwardDirection.Y:
|
||||||
material.SetInt("_Bend", 0);
|
material.SetInt("_Forward", 0);
|
||||||
material.DisableKeyword("_BEND_OFF");
|
|
||||||
material.DisableKeyword("_BEND_Y");
|
|
||||||
material.DisableKeyword("_BEND_Z");
|
|
||||||
break;
|
|
||||||
case Bend.Y:
|
|
||||||
material.SetInt("_Bend", 1);
|
|
||||||
material.DisableKeyword("_BEND_OFF");
|
|
||||||
material.EnableKeyword("_BEND_Y");
|
material.EnableKeyword("_BEND_Y");
|
||||||
material.DisableKeyword("_BEND_Z");
|
material.DisableKeyword("_BEND_Z");
|
||||||
break;
|
break;
|
||||||
case Bend.Z:
|
case MeshForwardDirection.Z:
|
||||||
material.SetInt("_Bend", 2);
|
material.SetInt("_Forward", 1);
|
||||||
material.DisableKeyword("_BEND_OFF");
|
|
||||||
material.DisableKeyword("_BEND_Y");
|
material.DisableKeyword("_BEND_Y");
|
||||||
material.EnableKeyword("_BEND_Z");
|
material.EnableKeyword("_BEND_Z");
|
||||||
break;
|
break;
|
||||||
@@ -84,6 +91,12 @@ public class Texture : MonoBehaviour
|
|||||||
set { material.SetFloat("_Width", value); }
|
set { material.SetFloat("_Width", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float thickness
|
||||||
|
{
|
||||||
|
get { return material.GetFloat("_Thickness"); }
|
||||||
|
set { material.SetFloat("_Thickness", value); }
|
||||||
|
}
|
||||||
|
|
||||||
public Material material
|
public Material material
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -92,18 +92,26 @@ inline fixed4 uddGetScreenTextureWithCursor(float2 uv)
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void uddBendVertex(inout float4 v, half radius, half width)
|
inline void uddBendVertex(inout float4 v, half radius, half width, half thickness)
|
||||||
{
|
{
|
||||||
#if !defined(_BEND_OFF)
|
#ifdef BEND_ON
|
||||||
half angle = width * v.x / radius;
|
half angle = width * v.x / radius;
|
||||||
#ifdef _BEND_Y
|
#ifdef _FORWARD_Z
|
||||||
|
v.y *= thickness;
|
||||||
radius -= v.y;
|
radius -= v.y;
|
||||||
v.y += radius * (1 - cos(angle));
|
v.y += radius * (1 - cos(angle));
|
||||||
#elif _BEND_Z
|
#elif _FORWARD_Y
|
||||||
|
v.z *= thickness;
|
||||||
radius -= v.z;
|
radius -= v.z;
|
||||||
v.z += radius * (1 - cos(angle));
|
v.z += radius * (1 - cos(angle));
|
||||||
#endif
|
#endif
|
||||||
v.x = radius * sin(angle) / width;
|
v.x = radius * sin(angle) / width;
|
||||||
|
#else
|
||||||
|
#ifdef _FORWARD_Z
|
||||||
|
v.y *= thickness;
|
||||||
|
#elif _FORWARD_Y
|
||||||
|
v.z *= thickness;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ Properties
|
|||||||
_Color ("Color", Color) = (1, 1, 1, 1)
|
_Color ("Color", Color) = (1, 1, 1, 1)
|
||||||
_MainTex ("Texture", 2D) = "white" {}
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
||||||
[KeywordEnum(Off, Y, Z)] _Bend("Bending", Int) = 0
|
[KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0
|
||||||
[PowerSlider(10.0)] _Radius("Radius", Range(1, 100)) = 30
|
[Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0
|
||||||
|
[PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30
|
||||||
|
[PowerSlider(10.0)] _Thickness("Thickness", Range(0.01, 10)) = 1
|
||||||
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,11 +26,12 @@ CGINCLUDE
|
|||||||
|
|
||||||
half _Radius;
|
half _Radius;
|
||||||
half _Width;
|
half _Width;
|
||||||
|
half _Thickness;
|
||||||
|
|
||||||
v2f vert(appdata v)
|
v2f vert(appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
uddBendVertex(v.vertex, _Radius, _Width);
|
uddBendVertex(v.vertex, _Radius, _Width, _Thickness);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
return o;
|
return o;
|
||||||
@@ -50,7 +53,8 @@ Pass
|
|||||||
#pragma multi_compile ___ INVERT_Y
|
#pragma multi_compile ___ INVERT_Y
|
||||||
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
|
#pragma multi_compile ___ ROTATE90 ROTATE180 ROTATE270
|
||||||
#pragma multi_compile ___ USE_CLIP
|
#pragma multi_compile ___ USE_CLIP
|
||||||
#pragma multi_compile _BEND_OFF _BEND_Y _BEND_Z
|
#pragma multi_compile ___ BEND_ON
|
||||||
|
#pragma multi_compile _FORWARD_Y _FORWARD_Z
|
||||||
ENDCG
|
ENDCG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ Properties
|
|||||||
_MainTex ("Texture", 2D) = "white" {}
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
_Mask ("Mask", Range(0, 1)) = 0.1
|
_Mask ("Mask", Range(0, 1)) = 0.1
|
||||||
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
||||||
[KeywordEnum(Off, Y, Z)] _Bend("Bending", Int) = 0
|
[KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0
|
||||||
[PowerSlider(10.0)] _Radius("Radius", Range(1, 100)) = 30
|
[Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0
|
||||||
|
[PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30
|
||||||
|
[PowerSlider(10.0)] _Thickness("Thickness", Range(0.01, 10)) = 1
|
||||||
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,11 +30,12 @@ CGINCLUDE
|
|||||||
fixed _Mask;
|
fixed _Mask;
|
||||||
half _Radius;
|
half _Radius;
|
||||||
half _Width;
|
half _Width;
|
||||||
|
half _Thickness;
|
||||||
|
|
||||||
v2f vert(appdata v)
|
v2f vert(appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
uddBendVertex(v.vertex, _Radius, _Width);
|
uddBendVertex(v.vertex, _Radius, _Width, _Thickness);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
return o;
|
return o;
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ Properties
|
|||||||
_Color ("Color", Color) = (1, 1, 1, 1)
|
_Color ("Color", Color) = (1, 1, 1, 1)
|
||||||
_MainTex ("Texture", 2D) = "white" {}
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
_CursorTex ("Cursor Texture", 2D) = "white" {}
|
||||||
[KeywordEnum(Off, Y, Z)] _Bend("Bending", Int) = 0
|
[KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0
|
||||||
[PowerSlider(10.0)] _Radius("Radius", Range(1, 100)) = 30
|
[Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0
|
||||||
|
[PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30
|
||||||
|
[PowerSlider(10.0)] _Thickness("Thickness", Range(0.01, 10)) = 1
|
||||||
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
[KeywordEnum(Off, Front, Back)] _Cull("Culling", Int) = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,11 +28,12 @@ CGINCLUDE
|
|||||||
|
|
||||||
half _Radius;
|
half _Radius;
|
||||||
half _Width;
|
half _Width;
|
||||||
|
half _Thickness;
|
||||||
|
|
||||||
v2f vert(appdata v)
|
v2f vert(appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
uddBendVertex(v.vertex, _Radius, _Width);
|
uddBendVertex(v.vertex, _Radius, _Width, _Thickness);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
return o;
|
return o;
|
||||||
|
|||||||
Reference in New Issue
Block a user