-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using Vuforia; | ||
|
||
public class CameraFocusController : MonoBehaviour { | ||
|
||
public bool mVuforiaStarted = false; | ||
|
||
void Start () | ||
{ | ||
VuforiaARController vuforia = VuforiaARController.Instance; | ||
|
||
if (vuforia != null) | ||
vuforia.RegisterVuforiaStartedCallback(StartAfterVuforia); | ||
} | ||
|
||
private void StartAfterVuforia() | ||
{ | ||
mVuforiaStarted = true; | ||
SetAutofocus(); | ||
} | ||
|
||
void OnApplicationPause(bool pause) | ||
{ | ||
if (!pause) | ||
{ | ||
// App resumed | ||
if (mVuforiaStarted) | ||
{ | ||
// App resumed and vuforia already started | ||
// but lets start it again... | ||
SetAutofocus(); // This is done because some android devices lose the auto focus after resume | ||
// this was a bug in vuforia 4 and 5. I haven't checked 6, but the code is harmless anyway | ||
} | ||
} | ||
} | ||
|
||
public void SetAutofocus() | ||
{ | ||
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO)) | ||
{ | ||
Debug.Log("Autofocus set"); | ||
} | ||
else | ||
{ | ||
// never actually seen a device that doesn't support this, but just in case | ||
Debug.Log("this device doesn't support auto focus"); | ||
} | ||
} | ||
|
||
public void SetFixedFocus() | ||
{ | ||
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_INFINITY)) | ||
{ | ||
Debug.Log("INFINITY FOCUS set"); | ||
} | ||
else | ||
{ | ||
// never actually seen a device that doesn't support this, but just in case | ||
Debug.Log("this device doesn't support auto focus"); | ||
} | ||
} | ||
|
||
public void RestartCamera() | ||
{ | ||
CameraDevice.Instance.Stop(); | ||
CameraDevice.Instance.Deinit(); | ||
|
||
CameraDevice.Instance.Init(); | ||
CameraDevice.Instance.Start(); | ||
|
||
VuforiaUnity.OnPause(); | ||
VuforiaUnity.OnResume(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
Shader "Ciconia Studio/Double Sided/Emissive/Diffuse" { | ||
Properties { | ||
_Color ("Diffuse Color", Color) = (1,1,1,1) | ||
_MainTex ("Diffuse map", 2D) = "white" {} | ||
_EmissiveIntensity ("Emissive Intensity", Range(0, 2)) = 1 | ||
} | ||
SubShader { | ||
Tags { | ||
"RenderType"="Opaque" | ||
} | ||
Pass { | ||
Name "FORWARD" | ||
Tags { | ||
"LightMode"="ForwardBase" | ||
} | ||
Cull Off | ||
|
||
|
||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#include "UnityCG.cginc" | ||
#pragma multi_compile_fwdbase_fullshadows | ||
#pragma multi_compile_fog | ||
#pragma only_renderers d3d9 d3d11 glcore gles gles3 metal d3d11_9x xboxone ps4 psp2 n3ds wiiu | ||
#pragma target 3.0 | ||
uniform sampler2D _MainTex; uniform float4 _MainTex_ST; | ||
uniform float4 _Color; | ||
uniform float _EmissiveIntensity; | ||
struct VertexInput { | ||
float4 vertex : POSITION; | ||
float2 texcoord0 : TEXCOORD0; | ||
}; | ||
struct VertexOutput { | ||
float4 pos : SV_POSITION; | ||
float2 uv0 : TEXCOORD0; | ||
UNITY_FOG_COORDS(1) | ||
}; | ||
VertexOutput vert (VertexInput v) { | ||
VertexOutput o = (VertexOutput)0; | ||
o.uv0 = v.texcoord0; | ||
o.pos = UnityObjectToClipPos( v.vertex ); | ||
UNITY_TRANSFER_FOG(o,o.pos); | ||
return o; | ||
} | ||
float4 frag(VertexOutput i, float facing : VFACE) : COLOR { | ||
float isFrontFace = ( facing >= 0 ? 1 : 0 ); | ||
float faceSign = ( facing >= 0 ? 1 : -1 ); | ||
////// Lighting: | ||
////// Emissive: | ||
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex)); | ||
float3 emissive = ((_MainTex_var.rgb*_Color.rgb)*_EmissiveIntensity); | ||
float3 finalColor = emissive; | ||
fixed4 finalRGBA = fixed4(finalColor,1); | ||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA); | ||
return finalRGBA; | ||
} | ||
ENDCG | ||
} | ||
Pass { | ||
Name "ShadowCaster" | ||
Tags { | ||
"LightMode"="ShadowCaster" | ||
} | ||
Offset 1, 1 | ||
Cull Off | ||
|
||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#include "UnityCG.cginc" | ||
#include "Lighting.cginc" | ||
#pragma fragmentoption ARB_precision_hint_fastest | ||
#pragma multi_compile_shadowcaster | ||
#pragma multi_compile_fog | ||
#pragma only_renderers d3d9 d3d11 glcore gles gles3 metal d3d11_9x xboxone ps4 psp2 n3ds wiiu | ||
#pragma target 3.0 | ||
struct VertexInput { | ||
float4 vertex : POSITION; | ||
}; | ||
struct VertexOutput { | ||
V2F_SHADOW_CASTER; | ||
}; | ||
VertexOutput vert (VertexInput v) { | ||
VertexOutput o = (VertexOutput)0; | ||
o.pos = UnityObjectToClipPos( v.vertex ); | ||
TRANSFER_SHADOW_CASTER(o) | ||
return o; | ||
} | ||
float4 frag(VertexOutput i, float facing : VFACE) : COLOR { | ||
float isFrontFace = ( facing >= 0 ? 1 : 0 ); | ||
float faceSign = ( facing >= 0 ? 1 : -1 ); | ||
SHADOW_CASTER_FRAGMENT(i) | ||
} | ||
ENDCG | ||
} | ||
} | ||
FallBack "Diffuse" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.