com.github.asus4.texture-source 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Texture2D<float4> _InputTex;
4
4
  RWTexture2D<float4> _OutputTex;
5
- int2 _OutputTexSize;
5
+ uint2 _OutputTexSize;
6
6
  float4x4 _TransformMatrix;
7
7
 
8
8
  SamplerState linearClampSampler;
@@ -15,7 +15,7 @@ void TextureTransform (uint2 id : SV_DispatchThreadID)
15
15
  return;
16
16
  }
17
17
 
18
- float2 uv = float2(id.x, id.y) / float2(_OutputTexSize.x, _OutputTexSize.y);
18
+ float2 uv = (float2)id / float2(_OutputTexSize - 1.0);
19
19
  uv = mul(_TransformMatrix, float4(uv, 0, 1)).xy;
20
20
 
21
21
  _OutputTex[id] = any(uv < 0) || any(uv > 1)
@@ -39,6 +39,17 @@ namespace TextureSource
39
39
  public bool DidUpdateThisFrame => activeSource.DidUpdateThisFrame;
40
40
  public Texture Texture => activeSource.Texture;
41
41
 
42
+ public BaseTextureSource Source
43
+ {
44
+ get => source;
45
+ set => source = value;
46
+ }
47
+ public BaseTextureSource SourceForEditor
48
+ {
49
+ get => sourceForEditor;
50
+ set => sourceForEditor = value;
51
+ }
52
+
42
53
  private void OnEnable()
43
54
  {
44
55
  activeSource = sourceForEditor != null && Application.isEditor
@@ -57,12 +57,48 @@ namespace TextureSource
57
57
  private int lastUpdatedFrame = -1;
58
58
  private bool isFrontFacing;
59
59
 
60
+ public WebCamKindFlag KindFilter
61
+ {
62
+ get => kindFilter;
63
+ set => kindFilter = value;
64
+ }
65
+
66
+ public FacingFlag FacingFilter
67
+ {
68
+ get => facingFilter;
69
+ set => facingFilter = value;
70
+ }
71
+
72
+ public Vector2Int Resolution
73
+ {
74
+ get => resolution;
75
+ set => resolution = value;
76
+ }
77
+
78
+ public bool IsFrontFacing => isFrontFacing;
79
+
80
+ public int FrameRate
81
+ {
82
+ get => frameRate;
83
+ set => frameRate = value;
84
+ }
85
+
60
86
  public override void Start()
61
87
  {
62
88
  devices = WebCamTexture.devices.Where(IsMatchFilter).ToArray();
63
89
  StartCamera(currentIndex);
64
90
  }
65
91
 
92
+ private void StartCamera(int index)
93
+ {
94
+ Stop();
95
+ WebCamDevice device = devices[index];
96
+ webCamTexture = new WebCamTexture(device.name, resolution.x, resolution.y, frameRate);
97
+ webCamTexture.Play();
98
+ isFrontFacing = device.isFrontFacing;
99
+ lastUpdatedFrame = -1;
100
+ }
101
+
66
102
  public override void Stop()
67
103
  {
68
104
  if (webCamTexture != null)
@@ -80,17 +116,6 @@ namespace TextureSource
80
116
  StartCamera(currentIndex);
81
117
  }
82
118
 
83
- private void StartCamera(int index)
84
- {
85
- Stop();
86
- WebCamDevice device = devices[index];
87
- webCamTexture = new WebCamTexture(device.name, resolution.x, resolution.y, frameRate);
88
- webCamTexture.Play();
89
- isFrontFacing = device.isFrontFacing;
90
- lastUpdatedFrame = -1;
91
- Debug.Log($"Started camera:{device.name}");
92
- }
93
-
94
119
  private RenderTexture NormalizeWebCam()
95
120
  {
96
121
  if (webCamTexture == null)
package/package.json CHANGED
@@ -9,6 +9,6 @@
9
9
  "license": "SEE LICENSE IN LICENSE",
10
10
  "unity": "2020.3",
11
11
  "unityRelease": "0f1",
12
- "version": "0.1.1",
12
+ "version": "0.1.3",
13
13
  "type": "tool"
14
14
  }