Added VR libraries

This commit is contained in:
Chris Midkiff
2018-10-08 23:54:11 -04:00
parent d9eb2a9763
commit 7ce1036e39
1037 changed files with 195630 additions and 348 deletions

View File

@@ -0,0 +1,45 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Particles/Additive Overlay" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category {
Tags {
"Queue"="Overlay+100"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 66ce34a5829a64856be634609edd8912
timeCreated: 1479169225
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,161 @@
// Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Unlit/Controller" {
Properties {
_Color ("Color", COLOR) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags {
"Queue" = "Overlay+100"
"IgnoreProjector" = "True"
"RenderType"="Transparent"
}
LOD 100
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
/// The size of the touch display. A value of 1 sets the radius to equal the touchpad radius
#define _GVR_DISPLAY_RADIUS .25
// How opaque is the battery indicator when illuminated
#define _GVR_BATTERY_ACTIVE_ALPHA 0.9
//How opaque is the battery indicator when not illuminated
#define _GVR_BATTERY_OFF_ALPHA 0.25
// How much do the app and system buttons depress when pushed
#define _BUTTON_PRESS_DEPTH 0.001
// Larger values tighten the feather
#define _TOUCH_FEATHER 8
/// The center of the touchpad in UV space
/// Only change this value if you also change the UV layout of the mesh
#define _GVR_TOUCHPAD_CENTER half2(.15, .85)
/// The radius of the touchpad in UV space, based on the geometry
/// Only change this value if you also change the UV layout of the mesh
#define _GVR_TOUCHPAD_RADIUS .139
struct appdata {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct v2f {
half2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
half4 color : TEXCOORD1;
half2 touchVector : TEXCOORD2;
half alpha : TEXCOORD3;
};
sampler2D _MainTex;
half4 _GvrControllerAlpha;
float4 _MainTex_ST;
half4 _Color;
half4 _GvrTouchPadColor;
half4 _GvrAppButtonColor;
half4 _GvrSystemButtonColor;
half4 _GvrBatteryColor;
half4 _GvrTouchInfo;//xy position, z touch duration, w battery info
v2f vert (appdata v) {
v2f o;
float4 vertex4;
vertex4.xyz = v.vertex;
vertex4.w = 1.0;
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = half4(0,0,0,0);
o.touchVector = half2(0,0);
half batteryOrController = saturate( 10.0 * (v.color.a - 0.6) );
half batteryMask = saturate( 10.0 * (1 - v.color.a) );
half batteryLevelMask = saturate( 20.0 * (v.color.a - _GvrTouchInfo.w) );
o.alpha = batteryOrController;
o.color.a = _GvrBatteryColor.a * batteryMask * (batteryLevelMask * _GVR_BATTERY_ACTIVE_ALPHA + (1-batteryLevelMask)*_GVR_BATTERY_OFF_ALPHA);
o.color.rgb = batteryMask * (batteryLevelMask * _GvrBatteryColor.rgb);
// v.color.r = Touchpad, v.color.g = AppButton, v.color.b = SystemButton, v.color.a = BatteryIndicator
// Update touch vector info, but only if in the touchpad region.
//This is the distance between the scaled center of the touchpad in UV space, and the input coords
half2 touchPosition = ((v.uv - _GVR_TOUCHPAD_CENTER)/_GVR_TOUCHPAD_RADIUS - _GvrTouchInfo.xy);
// the duration of a press + minimum radius
half scaledInput = _GvrTouchInfo.z + _GVR_DISPLAY_RADIUS;
// Apply a cubic function, but make sure when press duration =1 , we cancel out the min radius
half bounced = 2 * (2 * scaledInput - scaledInput*scaledInput ) -
(1 - 2.0*_GVR_DISPLAY_RADIUS*_GVR_DISPLAY_RADIUS);
o.touchVector = v.color.r * ((2-bounced)*( (1 - _GvrControllerAlpha.y)/_GVR_DISPLAY_RADIUS ) *touchPosition);
// Apply colors based on masked values.
o.color.rgb += v.color.r * _GvrTouchInfo.z * _GvrTouchPadColor.rgb +
v.color.g * _GvrControllerAlpha.z * _GvrAppButtonColor.rgb +
v.color.b * _GvrControllerAlpha.w * _GvrSystemButtonColor.rgb;
o.color.a += v.color.r * _GvrTouchInfo.z +
v.color.g * _GvrControllerAlpha.z +
v.color.b * _GvrControllerAlpha.w;
// Animate position based on masked values.
vertex4.y -= v.color.g * _BUTTON_PRESS_DEPTH*_GvrControllerAlpha.z +
v.color.b * _BUTTON_PRESS_DEPTH*_GvrControllerAlpha.w;
o.vertex = UnityObjectToClipPos(vertex4);
return o;
}
fixed4 frag (v2f i) : SV_Target {
// Compute the length from a touchpoint, scale the value to control the edge sharpness.
half len = saturate(_TOUCH_FEATHER*(1-length(i.touchVector)) );
i.color = i.color *len;
half4 texcol = tex2D(_MainTex, i.uv);
half3 tintColor = (i.color.rgb + (1-i.color.a) * _Color.rgb);
// Tint the controller based on luminance
half luma = Luminance(tintColor);
tintColor = texcol.rgb *(tintColor + .25*(1-luma));
/// Battery indicator.
texcol.a = i.alpha * texcol.a + (1-i.alpha)*(texcol.r)* i.color.a;
texcol.rgb = i.alpha * tintColor + (1-i.alpha)*i.color.rgb;
texcol.a *= _GvrControllerAlpha.x;
return texcol;
}
ENDCG
}
}
FallBack "Unlit/Transparent"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fdbce15836bf64163856f689fdd67b2c
timeCreated: 1497972574
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Unlit/Controller Reticle" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="TransparentCutout"
}
LOD 100
Cull Back
Lighting Off
Offset -150, -150
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#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;
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) : SV_Target {
fixed4 col = tex2D(_MainTex, i.texcoord);
clip(col.a - 0.5);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 57e34a0b7bd8740c5922ce5840ba3ee8
timeCreated: 1499380370
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Reticle" {
Properties {
_Color ("Color", Color) = ( 1, 1, 1, 1 )
_InnerDiameter ("InnerDiameter", Range(0, 10.0)) = 1.5
_OuterDiameter ("OuterDiameter", Range(0.00872665, 10.0)) = 2.0
_DistanceInMeters ("DistanceInMeters", Range(0.0, 100.0)) = 2.0
}
SubShader {
Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent" }
Pass {
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest Off
Cull Back
Lighting Off
ZWrite Off
ZTest Always
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform float4 _Color;
uniform float _InnerDiameter;
uniform float _OuterDiameter;
uniform float _DistanceInMeters;
struct vertexInput {
float4 vertex : POSITION;
};
struct fragmentInput{
float4 position : SV_POSITION;
};
fragmentInput vert(vertexInput i) {
float scale = lerp(_OuterDiameter, _InnerDiameter, i.vertex.z);
float3 vert_out = float3(i.vertex.x * scale, i.vertex.y * scale, _DistanceInMeters);
fragmentInput o;
o.position = UnityObjectToClipPos (vert_out);
return o;
}
fixed4 frag(fragmentInput i) : SV_Target {
fixed4 ret = _Color;
return ret;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a3b352fc2ba734605a3df75466e600f0
timeCreated: 1446884502
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,117 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/UI/Overlay" {
Properties {
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
SubShader {
Tags {
// Overlay+110 fixes depth sorting between UI and controller.
"Queue"="Overlay+110"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil {
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass {
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile __ UNITY_UI_ALPHACLIP
struct appdata_t {
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
};
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
v2f vert(appdata_t IN) {
v2f OUT;
OUT.worldPosition = IN.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
OUT.texcoord = IN.texcoord;
#ifdef UNITY_HALF_TEXEL_OFFSET
OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1) * OUT.vertex.w;
#endif // UNITY_HALF_TEXEL_OFFSET
OUT.color = IN.color * _Color;
return OUT;
}
sampler2D _MainTex;
fixed4 frag(v2f IN) : SV_Target {
half4 color =
(tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif // UNITY_UI_ALPHACLIP
return color;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 36d276bd7b313441fbe34aadce7598ca
timeCreated: 1479426244
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/UI/Overlay Font" {
Properties {
[PerRendererData] _MainTex ("Font Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
FallBack "GoogleVR/UI/Overlay"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c259eeb26e96b4f1d8eeb8871bcfdac5
timeCreated: 1479426244
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Unlit/Texture Overlay" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Overlay+100" "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;
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);
UNITY_OPAQUE_ALPHA(col.a);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: adb9b18ac2466473a850d8acd17654a1
timeCreated: 1479438500
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Unlit/Transparent Overlay" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {
"Queue"="Overlay+100"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest Off
Cull Back
Lighting Off
ZWrite Off
ZTest Always
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
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1d94b17868379452aad02b04eb7b0e6e
timeCreated: 1478211415
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Shader "GoogleVR/Unlit/Transparent Overlay Color" {
Properties {
_Color ("Color", COLOR) = (1, 1, 1, 1)
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags {
"Queue" = "Overlay+100"
"IgnoreProjector" = "True"
"RenderType"="Transparent"
}
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata {
float3 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _Color;
float4 _MainTex_ST;
v2f vert (appdata v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target {
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
return col;
}
ENDCG
}
}
FallBack "Unlit/Transparent"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 06aa46b8e43675d43b204c3638e59767
timeCreated: 1475685719
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 40ad9c4f7e87f5248afb31340adc5b82
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
// <copyright file="VideoUnlitShader.cs" company="Google Inc.">
// Copyright (C) 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//
// This shader renders from OES_external_image textures which require special
// OpenGLES extensions and a special texture sampler.
//
Shader "GoogleVR/Video Unlit Shader" {
Properties {
_Gamma ("Video gamma", Range(0.01,3.0)) = 1.0
_MainTex ("Base (RGB)", 2D) = "white" {}
[KeywordEnum(None, TopBottom, LeftRight)] _StereoMode ("Stereo mode", Float) = 0
[Toggle(FLIP_X)] _FlipX ("Flip X", Float) = 0
}
SubShader {
Pass {
Tags { "RenderType" = "Opaque" }
Lighting Off
Cull Off
GLSLPROGRAM
#pragma only_renderers gles gles3
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
#pragma multi_compile ___ _STEREOMODE_TOPBOTTOM _STEREOMODE_LEFTRIGHT
#pragma multi_compile ___ FLIP_X
precision mediump int;
precision mediump float;
#ifdef VERTEX
uniform mat4 video_matrix;
uniform int unity_StereoEyeIndex;
varying vec2 uv;
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 untransformedUV = gl_MultiTexCoord0;
#ifdef FLIP_X
untransformedUV.x = 1.0 - untransformedUV.x;
#endif // FLIP_X
#ifdef _STEREOMODE_TOPBOTTOM
untransformedUV.y *= 0.5;
if (unity_StereoEyeIndex == 0) {
untransformedUV.y += 0.5;
}
#endif // _STEREOMODE_TOPBOTTOM
#ifdef _STEREOMODE_LEFTRIGHT
untransformedUV.x *= 0.5;
if (unity_StereoEyeIndex != 0) {
untransformedUV.x += 0.5;
}
#endif // _STEREOMODE_LEFTRIGHT
uv = (video_matrix * untransformedUV).xy;
}
#endif // VERTEX
#ifdef FRAGMENT
vec3 gammaCorrect(vec3 v, float gamma) {
return pow(v, vec3(1.0/gamma));
}
// Apply the gamma correction. One possible optimization that could
// be applied is if _Gamma == 2.0, then use gammaCorrectApprox since sqrt will be faster.
// Also, if _Gamma == 1.0, then there is no effect, so this call could be skipped all together.
vec4 gammaCorrect(vec4 v, float gamma) {
return vec4(gammaCorrect(v.xyz, gamma), v.w);
}
uniform float _Gamma;
uniform samplerExternalOES _MainTex;
varying vec2 uv;
void main() {
gl_FragColor = gammaCorrect(texture2D(_MainTex, uv), _Gamma);
}
#endif // FRAGMENT
ENDGLSL
}
}
Fallback "Unlit/Texture"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4b50a67a5a86e4093bf89c85cbc2c700
timeCreated: 1496431929
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: