Added VR libraries
This commit is contained in:
75
Assets/Oculus/VR/Resources/Cubemap Blit.shader
Normal file
75
Assets/Oculus/VR/Resources/Cubemap Blit.shader
Normal file
@@ -0,0 +1,75 @@
|
||||
Shader "Oculus/Cubemap Blit" {
|
||||
Properties{
|
||||
_MainTex("Base (RGB) Trans (A)", CUBE) = "white" {}
|
||||
_face("Face", Int) = 0
|
||||
_linearToSrgb("Perform linear-to-gamma conversion", Int) = 0
|
||||
_premultiply("Cubemap Blit", Int) = 0
|
||||
}
|
||||
SubShader{
|
||||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Pass{
|
||||
ZWrite Off
|
||||
ColorMask RGBA
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half3 cubedir : TEXCOORD0;
|
||||
};
|
||||
|
||||
samplerCUBE _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
int _face;
|
||||
int _linearToSrgb;
|
||||
int _premultiply;
|
||||
|
||||
v2f vert (appdata_t va)
|
||||
{
|
||||
v2f vo;
|
||||
vo.vertex = UnityObjectToClipPos(va.vertex);
|
||||
|
||||
//Face bases, assuming +x, -x, +z, -z, +y, -y with origin at bottom-left.
|
||||
float3 o[6] = { {1.0, -1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, -1.0, 1.0}, { 1.0, -1.0, -1.0} };
|
||||
float3 u[6] = { {0.0, 0.0, -1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0} };
|
||||
float3 v[6] = { {0.0, 1.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, -1.0}, { 0.0, 0.0, 1.0}, { 0.0, 1.0, 0.0}, { 0.0, 1.0, 0.0} };
|
||||
|
||||
//Map the input UV to the corresponding face basis.
|
||||
vo.cubedir = o[_face] + 2.0*va.texcoord.x * u[_face] + 2.0*(1.0 - va.texcoord.y) * v[_face];
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f vi) : COLOR
|
||||
{
|
||||
fixed4 col = texCUBE(_MainTex, vi.cubedir);
|
||||
|
||||
if (_linearToSrgb)
|
||||
{
|
||||
float3 S1 = sqrt(col.rgb);
|
||||
float3 S2 = sqrt(S1);
|
||||
float3 S3 = sqrt(S2);
|
||||
col.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * col.rgb;
|
||||
}
|
||||
|
||||
if (_premultiply)
|
||||
col.rgb *= col.a;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/Cubemap Blit.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/Cubemap Blit.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 561ccac587275c745aec500620f12fc7
|
||||
timeCreated: 1507678760
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Oculus/VR/Resources/OVRMRCameraFrame.shader
Normal file
99
Assets/Oculus/VR/Resources/OVRMRCameraFrame.shader
Normal file
@@ -0,0 +1,99 @@
|
||||
Shader "Oculus/OVRMRCameraFrame"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex("Main Texture", 2D) = "white" {}
|
||||
_Visible("Visible", Range(0.0,1.0)) = 1.0
|
||||
_ChromaAlphaCutoff("ChromaAlphaCutoff", Range(0.0,1.0)) = 0.01
|
||||
_ChromaToleranceA("ChromaToleranceA", Range(0.0,50.0)) = 20.0
|
||||
_ChromaToleranceB("ChromaToleranceB", Range(0.0,50.0)) = 15.0
|
||||
_ChromaShadows("ChromaShadows", Range(0.0,1.0)) = 0.02
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
AlphaTest Greater .01
|
||||
Fog{ Mode Off }
|
||||
LOD 100
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "OVRMRChromaKey.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
sampler2D _MaskTex;
|
||||
|
||||
float4 _TextureDimension; // (w, h, 1/w, 1/h)
|
||||
|
||||
fixed4 _Color;
|
||||
fixed _Visible;
|
||||
float4 _FlipParams; // (flip_h, flip_v, 0, 0)
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.vertex *= _Visible;
|
||||
o.texcoord = TRANSFORM_TEX(float2(v.texcoord.x, 1.0-v.texcoord.y), _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed GetMask(float2 uv)
|
||||
{
|
||||
return tex2D(_MaskTex, uv).r;
|
||||
}
|
||||
|
||||
fixed4 GetCameraColor(float2 colorUV)
|
||||
{
|
||||
fixed4 c = tex2D(_MainTex, colorUV) * _Color;
|
||||
return c;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 colorUV = i.texcoord;
|
||||
if (_FlipParams.x > 0.0)
|
||||
{
|
||||
colorUV.x = 1.0 - colorUV.x;
|
||||
}
|
||||
if (_FlipParams.y > 0.0)
|
||||
{
|
||||
colorUV.y = 1.0 - colorUV.y;
|
||||
}
|
||||
float mask = GetMask(float2(colorUV.x, 1.0 - colorUV.y));
|
||||
if (mask == 0.0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
float4 col = GetColorAfterChromaKey(colorUV, _TextureDimension.zw, 1.0);
|
||||
if (col.a < 0.0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/OVRMRCameraFrame.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/OVRMRCameraFrame.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bd7618c3fa0e4b4ab8e08dc3fadc376
|
||||
timeCreated: 1497574409
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
112
Assets/Oculus/VR/Resources/OVRMRCameraFrameLit.shader
Normal file
112
Assets/Oculus/VR/Resources/OVRMRCameraFrameLit.shader
Normal file
@@ -0,0 +1,112 @@
|
||||
Shader "Oculus/OVRMRCameraFrameLit" {
|
||||
Properties{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_MainTex("Albedo (RGB)", 2D) = "white" {}
|
||||
_DepthTex("Depth (cm)", 2D) = "black" {}
|
||||
_InconfidenceTex("Inconfidence (0-100)", 2D) = "black" {}
|
||||
_Visible("Visible", Range(0.0,1.0)) = 1.0
|
||||
}
|
||||
SubShader{
|
||||
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Lambert alpha:fade
|
||||
#pragma target 3.0
|
||||
|
||||
#include "OVRMRChromaKey.cginc"
|
||||
|
||||
#define TEST_ENVIRONMENT 0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _DepthTex;
|
||||
sampler2D _MaskTex;
|
||||
|
||||
float4 _TextureDimension; // (w, h, 1/w, 1/h)
|
||||
float4 _TextureWorldSize; // (width_in_meter, height_in_meter, 0, 0)
|
||||
|
||||
float _SmoothFactor;
|
||||
float _DepthVariationClamp;
|
||||
|
||||
float _CullingDistance;
|
||||
|
||||
struct Input {
|
||||
#if TEST_ENVIRONMENT
|
||||
float2 uv_MainTex;
|
||||
#endif
|
||||
float4 screenPos;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed _Visible;
|
||||
float4 _FlipParams; // (flip_h, flip_v, 0, 0)
|
||||
|
||||
fixed GetMask(float2 uv)
|
||||
{
|
||||
return tex2D(_MaskTex, uv).r;
|
||||
}
|
||||
|
||||
fixed4 GetCameraColor(float2 colorUV)
|
||||
{
|
||||
fixed4 c = tex2D(_MainTex, colorUV) * _Color;
|
||||
return c;
|
||||
}
|
||||
|
||||
float GetDepth(float2 uv)
|
||||
{
|
||||
float depth = tex2D(_DepthTex, uv).x * 1.0 / 100;
|
||||
return depth;
|
||||
}
|
||||
|
||||
float3 GetNormal(float2 uv)
|
||||
{
|
||||
float dz_x = GetDepth(uv + float2(_TextureDimension.z, 0)) - GetDepth(uv - float2(_TextureDimension.z, 0));
|
||||
float dz_y = GetDepth(uv + float2(0, _TextureDimension.w)) - GetDepth(uv - float2(0, _TextureDimension.w));
|
||||
dz_x = clamp(dz_x, -_DepthVariationClamp, _DepthVariationClamp);
|
||||
dz_y = clamp(dz_y, -_DepthVariationClamp, _DepthVariationClamp);
|
||||
//float dist = 0.01;
|
||||
//float3 normal = cross(float3(dist, 0, dz_x), float3(0, dist, dz_y));
|
||||
float3 normal = cross(float3(_TextureWorldSize.x * _TextureDimension.z * 2.0 * _SmoothFactor, 0, dz_x), float3(0, _TextureWorldSize.y * _TextureDimension.w * 2.0 * _SmoothFactor, dz_y));
|
||||
normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
void surf(Input IN, inout SurfaceOutput o) {
|
||||
#if TEST_ENVIRONMENT
|
||||
float2 colorUV = float2(IN.uv_MainTex.x, IN.uv_MainTex.y);
|
||||
#else
|
||||
float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
|
||||
float2 colorUV = float2(screenUV.x, 1.0 - screenUV.y);
|
||||
#endif
|
||||
if (_FlipParams.x > 0.0)
|
||||
{
|
||||
colorUV.x = 1.0 - colorUV.x;
|
||||
}
|
||||
if (_FlipParams.y > 0.0)
|
||||
{
|
||||
colorUV.y = 1.0 - colorUV.y;
|
||||
}
|
||||
float mask = GetMask(colorUV);
|
||||
if (mask == 0.0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
float4 col = GetColorAfterChromaKey(colorUV, _TextureDimension.zw, 1.0);
|
||||
if (col.a < 0.0)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
float depth = GetDepth(colorUV);
|
||||
if (depth > _CullingDistance)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
float3 normal = GetNormal(colorUV);
|
||||
o.Albedo = col.rgb;
|
||||
o.Normal = normal;
|
||||
o.Alpha = col.a *_Visible;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Alpha-Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8577c885e80d8043946ac5b7abcf9a1
|
||||
timeCreated: 1497574409
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
103
Assets/Oculus/VR/Resources/OVRMRChromaKey.cginc
Normal file
103
Assets/Oculus/VR/Resources/OVRMRChromaKey.cginc
Normal file
@@ -0,0 +1,103 @@
|
||||
fixed4 _ChromaKeyColor;
|
||||
float _ChromaKeySimilarity;
|
||||
float _ChromaKeySmoothRange;
|
||||
float _ChromaKeySpillRange;
|
||||
|
||||
// https://en.wikipedia.org/wiki/YUV
|
||||
float3 RGB2YUV(float3 rgb)
|
||||
{
|
||||
float r = rgb.x;
|
||||
float g = rgb.y;
|
||||
float b = rgb.z;
|
||||
float y = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
float u = -0.09991 * r - 0.33609 * g + 0.436 * b;
|
||||
float v = 0.615 * r - 0.55861 * g - 0.05639 * b;
|
||||
return float3(y, u, v);
|
||||
}
|
||||
|
||||
float3 YUV2RGB(float3 yuv)
|
||||
{
|
||||
float y = yuv.x;
|
||||
float u = yuv.y;
|
||||
float v = yuv.z;
|
||||
float r = y + 1.28033 * v;
|
||||
float g = y - 0.21482 * u - 0.38059 * v;
|
||||
float b = y + 2.12798 * u;
|
||||
return float3(r, g, b);
|
||||
}
|
||||
|
||||
fixed4 GetCameraColor(float2 colorUV);
|
||||
|
||||
float ColorDistance_YUV_YUV(float3 yuv1, float3 yuv2)
|
||||
{
|
||||
float dist = distance(yuv1.yz, yuv2.yz);
|
||||
// Increase the distance if the brightness of the first color is too high.
|
||||
// It fixed the error on the over exposure areas
|
||||
dist += saturate(yuv1.x - 0.9);
|
||||
return dist;
|
||||
}
|
||||
|
||||
float ColorDistance_RGB_YUV(float3 rgb1, float3 yuv2)
|
||||
{
|
||||
float3 yuv1 = RGB2YUV(rgb1);
|
||||
return ColorDistance_YUV_YUV(yuv1, yuv2);
|
||||
}
|
||||
|
||||
|
||||
float ColorDistance_RGB_RGB(float3 rgb1, float3 rgb2)
|
||||
{
|
||||
float3 yuv1 = RGB2YUV(rgb1);
|
||||
float3 yuv2 = RGB2YUV(rgb2);
|
||||
return ColorDistance_YUV_YUV(yuv1, yuv2);
|
||||
}
|
||||
|
||||
float RGB2Gray(float3 rgb)
|
||||
{
|
||||
float r = rgb.x;
|
||||
float g = rgb.y;
|
||||
float b = rgb.z;
|
||||
float y = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
return y;
|
||||
}
|
||||
|
||||
float GetAlphaFromDistance(float dist)
|
||||
{
|
||||
float result = smoothstep(_ChromaKeySimilarity, _ChromaKeySimilarity + _ChromaKeySmoothRange, dist);
|
||||
result = result * result;
|
||||
return result;
|
||||
}
|
||||
|
||||
float GetSpillFromDistance(float dist)
|
||||
{
|
||||
float result = smoothstep(_ChromaKeySimilarity, _ChromaKeySimilarity + _ChromaKeySpillRange, dist);
|
||||
result = result * result * result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
float4 GetColorAfterChromaKey(float2 UV, float2 deltaUV, float step)
|
||||
{
|
||||
float3 chromaColor = _ChromaKeyColor.rgb;
|
||||
float3 chromaYUV = RGB2YUV(chromaColor);
|
||||
float dist = 0.0;
|
||||
const int samples = 3;
|
||||
float offset = ((float)samples - 1.0) / 2.0;
|
||||
for (int i = 0; i < samples; ++i)
|
||||
{
|
||||
for (int j = 0; j < samples; ++j)
|
||||
{
|
||||
fixed4 color = GetCameraColor(UV + float2((float)i - offset, (float)j - offset) * deltaUV * step);
|
||||
float d = ColorDistance_RGB_YUV(color, chromaYUV);
|
||||
dist += d;
|
||||
}
|
||||
}
|
||||
dist /= (samples * samples);
|
||||
fixed4 centerColor = GetCameraColor(UV);
|
||||
float alpha = GetAlphaFromDistance(dist);
|
||||
float spill = GetSpillFromDistance(dist);
|
||||
float gray = RGB2Gray(centerColor.rgb);
|
||||
float4 outColor;
|
||||
outColor.rgb = lerp(float3(gray, gray, gray), centerColor.rgb, spill);
|
||||
outColor.a = alpha;
|
||||
return outColor;
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/OVRMRChromaKey.cginc.meta
Normal file
9
Assets/Oculus/VR/Resources/OVRMRChromaKey.cginc.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 680577023e93e564c9b00f18b0164afa
|
||||
timeCreated: 1503944830
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Oculus/VR/Resources/OVRMRClipPlane.shader
Normal file
50
Assets/Oculus/VR/Resources/OVRMRClipPlane.shader
Normal file
@@ -0,0 +1,50 @@
|
||||
Shader "Oculus/OVRMRClipPlane"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Chroma Key Color", Color) = (0,1,0,1)
|
||||
_Visible("Visible", Range(0.0,1.0)) = 1.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed _Visible;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.vertex *= _Visible;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = _Color;
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/OVRMRClipPlane.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/OVRMRClipPlane.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ab721dccaa7e6f4693cedd904dfdcac
|
||||
timeCreated: 1494743027
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Oculus/VR/Resources/OVRMRUnlit.shader
Normal file
48
Assets/Oculus/VR/Resources/OVRMRUnlit.shader
Normal file
@@ -0,0 +1,48 @@
|
||||
Shader "Oculus/Unlit" {
|
||||
Properties{
|
||||
_Color("Main Color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader{
|
||||
Tags{ "RenderType" = "Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_FOG_COORDS(0)
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed4 col = _Color;
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
UNITY_OPAQUE_ALPHA(col.a);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/OVRMRUnlit.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/OVRMRUnlit.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aa46566e1d86644c9a55e3037e935f6
|
||||
timeCreated: 1504826310
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Oculus/VR/Resources/OVRMRUnlitTransparent.shader
Normal file
54
Assets/Oculus/VR/Resources/OVRMRUnlitTransparent.shader
Normal file
@@ -0,0 +1,54 @@
|
||||
Shader "Oculus/UnlitTransparent" {
|
||||
Properties{
|
||||
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader{
|
||||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
LOD 100
|
||||
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38ad33c152e32ee46a9bbbb0e656f7e1
|
||||
timeCreated: 1504826310
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Oculus/VR/Resources/Texture2D Blit.shader
Normal file
64
Assets/Oculus/VR/Resources/Texture2D Blit.shader
Normal file
@@ -0,0 +1,64 @@
|
||||
Shader "Oculus/Texture2D Blit" {
|
||||
Properties{
|
||||
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_linearToSrgb("Perform linear-to-gamma conversion", Int) = 0
|
||||
_premultiply("Pre-multiply alpha", Int) = 0
|
||||
}
|
||||
SubShader{
|
||||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Pass{
|
||||
ZWrite Off
|
||||
ColorMask RGBA
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
int _linearToSrgb;
|
||||
int _premultiply;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.texcoord);
|
||||
if (_linearToSrgb)
|
||||
{
|
||||
float3 S1 = sqrt(col.rgb);
|
||||
float3 S2 = sqrt(S1);
|
||||
float3 S3 = sqrt(S2);
|
||||
col.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * col.rgb;
|
||||
}
|
||||
|
||||
if (_premultiply)
|
||||
col.rgb *= col.a;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/Texture2D Blit.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/Texture2D Blit.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a31796e9e8816c7448b55d584c9417f1
|
||||
timeCreated: 1498190241
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Oculus/VR/Resources/Underlay Impostor.shader
Normal file
48
Assets/Oculus/VR/Resources/Underlay Impostor.shader
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
This shader is used to render the impostor while clearing out the alpha of the eye buffer
|
||||
The important details here are:
|
||||
- the use of the Geometry+1 queue to make sure the impostor is drawn after all other opaque objects but before alpha
|
||||
- the keepalpha parameter that allow unity to actually write the alpha we return at the end of the shader.
|
||||
*/
|
||||
|
||||
Shader "Oculus/Underlay Impostor" {
|
||||
Properties{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_MainTex("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic("Metallic", Range(0,1)) = 0.0
|
||||
}
|
||||
SubShader{
|
||||
Tags { "Queue" = "Geometry+1" "RenderType" = "Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows keepalpha
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
void surf(Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = 0.f;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
9
Assets/Oculus/VR/Resources/Underlay Impostor.shader.meta
Normal file
9
Assets/Oculus/VR/Resources/Underlay Impostor.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaeac9ce83896a04691d2590189776f5
|
||||
timeCreated: 1471282585
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Code for transparent object in front of the overlay
|
||||
The keepalpha option is important to let unity maintain the alpha we return from the shader
|
||||
*/
|
||||
|
||||
Shader "Oculus/Underlay Transparent Occluder" {
|
||||
Properties{
|
||||
_Color("Main Color", Color) = (1,1,1,1)
|
||||
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
}
|
||||
SubShader{
|
||||
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
// extra pass that renders to depth buffer only
|
||||
Pass{
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Lambert keepalpha
|
||||
fixed4 _Color;
|
||||
struct Input {
|
||||
float4 color : COLOR;
|
||||
};
|
||||
void surf(Input IN, inout SurfaceOutput o) {
|
||||
o.Albedo = _Color.rgb;
|
||||
o.Alpha = _Color.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
Fallback "Transparent/VertexLit"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6708eb99dec8334fb83db57b764097a
|
||||
timeCreated: 1470867310
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Oculus/VR/Resources/Unlit Transparent Color.shader
Normal file
17
Assets/Oculus/VR/Resources/Unlit Transparent Color.shader
Normal file
@@ -0,0 +1,17 @@
|
||||
Shader "Oculus/Unlit Transparent Color" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
Fog {Mode Off}
|
||||
|
||||
ZTest Always
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Color [_Color]
|
||||
|
||||
Pass {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ced943c76cb8fb8489bab18c3dfcdcd3
|
||||
timeCreated: 1435284538
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user