Skip to content

Commit faae9b0

Browse files
author
surface
committed
v1.0.0
0 parents  commit faae9b0

File tree

82 files changed

+26867
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+26867
-0
lines changed

Assets/NrealLightWithOpenCVForUnityExample.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/NrealLightWithOpenCVForUnityExample/Materials.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Shader "Unlit/GreyScaleShader" {
2+
Properties{
3+
_MainTex("Texture", 2D) = "white" { }
4+
}
5+
SubShader{
6+
Pass {
7+
8+
CGPROGRAM
9+
#pragma vertex vert
10+
#pragma fragment frag
11+
12+
#include "UnityCG.cginc"
13+
14+
sampler2D _MainTex;
15+
16+
struct v2f {
17+
float4 pos : SV_POSITION;
18+
float2 uv : TEXCOORD0;
19+
};
20+
21+
float4 _MainTex_ST;
22+
23+
v2f vert(appdata_base v)
24+
{
25+
v2f o;
26+
o.pos = UnityObjectToClipPos(v.vertex);
27+
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
28+
return o;
29+
}
30+
31+
fixed4 frag(v2f i) : COLOR
32+
{
33+
float texcol_a = tex2D(_MainTex, i.uv).a;
34+
return fixed4(texcol_a, texcol_a, texcol_a, 1.0f);
35+
}
36+
37+
ENDCG
38+
}
39+
}
40+
Fallback "VertexLit"
41+
}

Assets/NrealLightWithOpenCVForUnityExample/Materials/grayscaleShader.shader.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
2+
3+
Shader "AR/HolographicImageBlendGrayscaleShader"
4+
{
5+
// Referring to https://forum.unity3d.com/threads/holographic-photo-blending-with-photocapture.416023/.
6+
7+
Properties
8+
{
9+
_MainTex ("Texture", 2D) = "white" {}
10+
_VignetteScale ("Vignette Scale", RANGE(0,2)) = 0
11+
_VignetteOffset ("Vignette Offset" , Vector) = (0,0,0,0)
12+
}
13+
SubShader
14+
{
15+
Tags { "RenderType"="Opaque" }
16+
LOD 100
17+
18+
Pass
19+
{
20+
CGPROGRAM
21+
#pragma vertex vert
22+
#pragma fragment frag
23+
24+
#include "UnityCG.cginc"
25+
26+
struct appdata
27+
{
28+
float4 vertex : POSITION;
29+
};
30+
31+
struct v2f
32+
{
33+
float4 vertexPositionInProjectionSpace : SV_POSITION;
34+
float2 uv : TEXCOORD0;
35+
float4 vertexInProjectionSpace : TEXCOORD1;
36+
};
37+
38+
sampler2D _MainTex;
39+
float4x4 _WorldToCameraMatrix;
40+
float4x4 _CameraProjectionMatrix;
41+
float _VignetteScale;
42+
float4 _VignetteOffset;
43+
44+
v2f vert (appdata v)
45+
{
46+
v2f o;
47+
o.vertexPositionInProjectionSpace = UnityObjectToClipPos(v.vertex);
48+
49+
// Calculate the vertex position in world space.
50+
float4 vertexPositionInWorldSpace = mul(unity_ObjectToWorld, float4(v.vertex.xyz,1));
51+
// Now take the world space vertex position and transform it so that
52+
// it is relative to the physical web camera on the HoloLens.
53+
float4 vertexPositionInCameraSpace = mul(_WorldToCameraMatrix, float4(vertexPositionInWorldSpace.xyz,1));
54+
55+
// Convert our camera relative vertex into clip space.
56+
o.vertexInProjectionSpace = mul(_CameraProjectionMatrix, float4(vertexPositionInCameraSpace.xyz, 1.0));
57+
58+
return o;
59+
}
60+
61+
fixed4 frag (v2f i) : SV_Target
62+
{
63+
// Transform the vertex into normalized coordinate space. Basically
64+
// we want to map where our vertex should be on the screen into the -1 to 1 range
65+
// for both the x and y axes.
66+
float2 signedUV = i.vertexInProjectionSpace.xy / i.vertexInProjectionSpace.w;
67+
68+
// The HoloLens uses an additive display so the color black will
69+
// be transparent. If the texture is smaller than the canvas, color the extra
70+
// area on the canvas black so it will be transparent on the HoloLens.
71+
if(abs(signedUV.x) > 1.0 || abs(signedUV.y) > 1.0)
72+
{
73+
return fixed4( 0.0, 0.0, 0.0, 0.0);
74+
}
75+
76+
// Currently our signedUV's x and y coordinates will fall between -1 and 1.
77+
// We need to map this range from 0 to 1 so that we can sample our texture.
78+
float2 uv = signedUV * 0.5 + float2(0.5, 0.5);
79+
float texcol_a = tex2D(_MainTex, uv).a;
80+
fixed4 finalColor = fixed4(texcol_a, texcol_a, texcol_a, 1.0f);
81+
82+
// Finally add a circular vignette effect starting from the center
83+
// of the image.
84+
signedUV.x = signedUV.x + _VignetteOffset.x*2;
85+
signedUV.y = signedUV.y + _VignetteOffset.y*2;
86+
finalColor *= 1.0 -(length(signedUV) * _VignetteScale);
87+
88+
return finalColor;
89+
}
90+
91+
ENDCG
92+
}
93+
}
94+
}

Assets/NrealLightWithOpenCVForUnityExample/Materials/holographicImageBlendGrayscaleShader.shader.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: holographicImageBlendGrayscale_material
11+
m_Shader: {fileID: 4800000, guid: b31aa24f8b8045b479ee2194b93a28f4, type: 3}
12+
m_ShaderKeywords:
13+
m_LightmapFlags: 5
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: -1
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _MainTex:
23+
m_Texture: {fileID: 0}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
m_Floats:
27+
- _VignetteScale: 0
28+
m_Colors:
29+
- _Color: {r: 1, g: 1, b: 1, a: 1}
30+
- _VignetteOffset: {r: 0, g: 0, b: 0, a: 0}
31+
m_BuildTextureStacks: []

Assets/NrealLightWithOpenCVForUnityExample/Materials/holographicImageBlendGrayscale_material.mat.meta

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
2+
3+
Shader "AR/HolographicImageBlendShader"
4+
{
5+
// Referring to https://forum.unity3d.com/threads/holographic-photo-blending-with-photocapture.416023/.
6+
7+
Properties
8+
{
9+
_MainTex ("Texture", 2D) = "white" {}
10+
_VignetteScale ("Vignette Scale", RANGE(0,2)) = 0
11+
_VignetteOffset ("Vignette Offset" , Vector) = (0,0,0,0)
12+
}
13+
SubShader
14+
{
15+
Tags { "RenderType"="Opaque" }
16+
LOD 100
17+
18+
Pass
19+
{
20+
CGPROGRAM
21+
#pragma vertex vert
22+
#pragma fragment frag
23+
24+
#include "UnityCG.cginc"
25+
26+
struct appdata
27+
{
28+
float4 vertex : POSITION;
29+
};
30+
31+
struct v2f
32+
{
33+
float4 vertexPositionInProjectionSpace : SV_POSITION;
34+
float2 uv : TEXCOORD0;
35+
float4 vertexInProjectionSpace : TEXCOORD1;
36+
};
37+
38+
sampler2D _MainTex;
39+
float4x4 _WorldToCameraMatrix;
40+
float4x4 _CameraProjectionMatrix;
41+
float _VignetteScale;
42+
float4 _VignetteOffset;
43+
44+
v2f vert (appdata v)
45+
{
46+
v2f o;
47+
o.vertexPositionInProjectionSpace = UnityObjectToClipPos(v.vertex);
48+
49+
// Calculate the vertex position in world space.
50+
float4 vertexPositionInWorldSpace = mul(unity_ObjectToWorld, float4(v.vertex.xyz,1));
51+
// Now take the world space vertex position and transform it so that
52+
// it is relative to the physical web camera on the HoloLens.
53+
float4 vertexPositionInCameraSpace = mul(_WorldToCameraMatrix, float4(vertexPositionInWorldSpace.xyz,1));
54+
55+
// Convert our camera relative vertex into clip space.
56+
o.vertexInProjectionSpace = mul(_CameraProjectionMatrix, float4(vertexPositionInCameraSpace.xyz, 1.0));
57+
58+
return o;
59+
}
60+
61+
fixed4 frag (v2f i) : SV_Target
62+
{
63+
// Transform the vertex into normalized coordinate space. Basically
64+
// we want to map where our vertex should be on the screen into the -1 to 1 range
65+
// for both the x and y axes.
66+
float2 signedUV = i.vertexInProjectionSpace.xy / i.vertexInProjectionSpace.w;
67+
68+
// The HoloLens uses an additive display so the color black will
69+
// be transparent. If the texture is smaller than the canvas, color the extra
70+
// area on the canvas black so it will be transparent on the HoloLens.
71+
if(abs(signedUV.x) > 1.0 || abs(signedUV.y) > 1.0)
72+
{
73+
return fixed4( 0.0, 0.0, 0.0, 0.0);
74+
}
75+
76+
// Currently our signedUV's x and y coordinates will fall between -1 and 1.
77+
// We need to map this range from 0 to 1 so that we can sample our texture.
78+
float2 uv = signedUV * 0.5 + float2(0.5, 0.5);
79+
fixed4 finalColor = tex2D(_MainTex, uv);
80+
81+
// Finally add a circular vignette effect starting from the center
82+
// of the image.
83+
signedUV.x = signedUV.x + _VignetteOffset.x*2;
84+
signedUV.y = signedUV.y + _VignetteOffset.y*2;
85+
finalColor *= 1.0 -(length(signedUV) * _VignetteScale);
86+
87+
return finalColor;
88+
}
89+
ENDCG
90+
}
91+
}
92+
}

Assets/NrealLightWithOpenCVForUnityExample/Materials/holographicImageBlendShader.shader.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: holographicImageBlend_material
11+
m_Shader: {fileID: 4800000, guid: b49e2ae1f722d26489c05b7dcf46e5fe, type: 3}
12+
m_ShaderKeywords:
13+
m_LightmapFlags: 5
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: -1
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _MainTex:
23+
m_Texture: {fileID: 0}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
m_Floats:
27+
- _VignetteScale: 0
28+
m_Colors:
29+
- _Color: {r: 1, g: 1, b: 1, a: 1}
30+
- _VignetteOffset: {r: 0, g: 0, b: 0, a: 0}
31+
m_BuildTextureStacks: []

Assets/NrealLightWithOpenCVForUnityExample/Materials/holographicImageBlend_material.mat.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: quadGrayscale_material
11+
m_Shader: {fileID: 4800000, guid: 8c80e077702481e4785a2b78da273469, type: 3}
12+
m_ShaderKeywords:
13+
m_LightmapFlags: 5
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: -1
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _MainTex:
23+
m_Texture: {fileID: 2800000, guid: e266aedc629209a4196966ac4bf20d68, type: 3}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
m_Floats:
27+
- _VignetteScale: 0
28+
m_Colors:
29+
- _Color: {r: 1, g: 1, b: 1, a: 1}
30+
- _VignetteOffset: {r: 0, g: 0, b: 0, a: 0}

Assets/NrealLightWithOpenCVForUnityExample/Materials/quadGrayscale_material.mat.meta

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)