com.github.asus4.texture-source 0.2.1 → 0.2.2
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.
package/README.md
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
# Texture Source
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/com.github.asus4.texture-source)
|
|
4
|
+
|
|
3
5
|
TextureSource is a utility that provides a consistent API to get the texture from various sources.
|
|
4
6
|
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Example API Usage
|
|
10
|
+
|
|
11
|
+
```c#
|
|
12
|
+
using TextureSource;
|
|
13
|
+
using UnityEngine;
|
|
14
|
+
|
|
15
|
+
[RequireComponent(typeof(VirtualTextureSource))]
|
|
16
|
+
public class TextureSourceSample: MonoBehaviour
|
|
17
|
+
{
|
|
18
|
+
private void Start()
|
|
19
|
+
{
|
|
20
|
+
// Listen to OnTexture event from VirtualTextureSource
|
|
21
|
+
// Also able to bind in the inspector
|
|
22
|
+
if (TryGetComponent(out VirtualTextureSource source))
|
|
23
|
+
{
|
|
24
|
+
source.OnTexture.AddListener(OnTexture);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private void OnDestroy()
|
|
29
|
+
{
|
|
30
|
+
if (TryGetComponent(out VirtualTextureSource source))
|
|
31
|
+
{
|
|
32
|
+
source.OnTexture.RemoveListener(OnTexture);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public void OnTexture(Texture texture)
|
|
37
|
+
{
|
|
38
|
+
// Do whatever 🥳
|
|
39
|
+
// You don't need to think about webcam texture rotation.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
5
44
|
## Install via UPM
|
|
6
45
|
|
|
7
46
|
Add the following setting to `Packages/manifest.json`
|
|
@@ -18,7 +57,7 @@ Add the following setting to `Packages/manifest.json`
|
|
|
18
57
|
}
|
|
19
58
|
],
|
|
20
59
|
"dependencies": {
|
|
21
|
-
"com.github.asus4.texture-source": "0.2.
|
|
60
|
+
"com.github.asus4.texture-source": "0.2.2",
|
|
22
61
|
...// other dependencies
|
|
23
62
|
}
|
|
24
63
|
}
|
|
@@ -30,29 +69,29 @@ After installing the library, attach `VirtualTextureSource` to the GameObject.
|
|
|
30
69
|
|
|
31
70
|

|
|
32
71
|
|
|
33
|
-
Then, right-click on the project panel and create the
|
|
72
|
+
Then, right-click on the project panel and create the TextureSource scriptable object that you want to use. You can set different sources for the Editor and Runtime.
|
|
34
73
|
|
|
35
74
|

|
|
36
75
|
|
|
37
76
|
Currently provides the following sources:
|
|
38
77
|
|
|
39
|
-
|
|
78
|
+
### WebCam Texture Source
|
|
40
79
|
|
|
41
80
|
Includes collecting device rotation.
|
|
42
81
|
|
|
43
82
|

|
|
44
83
|
|
|
45
|
-
|
|
84
|
+
### Video Texture Source
|
|
46
85
|
|
|
47
86
|
Useful when using test videos only in the Editor.
|
|
48
87
|
|
|
49
88
|

|
|
50
89
|
|
|
51
|
-
|
|
90
|
+
### AR Foundation Texture Source
|
|
52
91
|
|
|
53
92
|
Provides AR camera texture access. It supports both ARCore/ARKit.
|
|
54
93
|
|
|
55
|
-

|
|
56
95
|
|
|
57
96
|
## Acknowledgement
|
|
58
97
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
#pragma kernel TextureTransform
|
|
2
2
|
|
|
3
|
-
#include "Common.hlsl"
|
|
4
|
-
|
|
5
3
|
Texture2D<float4> _InputTex;
|
|
6
4
|
RWTexture2D<float4> _OutputTex;
|
|
7
5
|
uint2 _OutputTexSize;
|
|
@@ -22,10 +20,6 @@ void TextureTransform (uint2 id : SV_DispatchThreadID)
|
|
|
22
20
|
|
|
23
21
|
float4 c = _InputTex.SampleLevel(linearClampSampler, uv, 0);
|
|
24
22
|
|
|
25
|
-
#ifndef UNITY_NO_LINEAR_COLORSPACE
|
|
26
|
-
c.rgb = FastSRGBToLinear(c.rgb);
|
|
27
|
-
#endif // !UNITY_COLORSPACE_GAMMA
|
|
28
|
-
|
|
29
23
|
_OutputTex[id] = any(uv < 0) || any(uv > 1)
|
|
30
24
|
? float4(0, 0, 0, 1)
|
|
31
25
|
: c;
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Ported from RenderPipeLine-Core, to support both URP and Built-in RP in one shader
|
|
2
|
-
// com.unity.render-pipelines.core copyright © 2020 Unity Technologies ApS
|
|
3
|
-
// Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
|
|
4
|
-
|
|
5
|
-
float3 FastSRGBToLinear(float3 c)
|
|
6
|
-
{
|
|
7
|
-
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
|
|
8
|
-
}
|