-
Notifications
You must be signed in to change notification settings - Fork 8
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,92 @@ | ||
Shader "CylindricalUnwrap" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Texture", 2D) = "white" {} | ||
} | ||
SubShader | ||
{ | ||
Tags { "RenderType"="Opaque" } | ||
LOD 100 | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata | ||
{ | ||
float4 vertex : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float4 _MainTex_ST; | ||
|
||
v2f vert (appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); | ||
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | ||
return o; | ||
} | ||
|
||
fixed4 frag (v2f i) : SV_Target | ||
{ | ||
float PI = 3.14159265; | ||
|
||
float angle; | ||
float azim; | ||
float dist; | ||
|
||
float get_s, get_t, pos_s; | ||
|
||
angle = i.uv.x * 360.0 - 180.0; | ||
|
||
if (angle >= -180.0 && angle < -90.0) { | ||
azim = angle+180.0 - 45.0; | ||
pos_s = 0.0; | ||
} | ||
|
||
if (angle >= -90.0 && angle < 0.0) { | ||
azim = angle + 45.0; | ||
pos_s = 0.25; | ||
} | ||
|
||
if (angle >= 0.0 && angle < 90.0) { | ||
azim = angle - 45.0; | ||
pos_s = 0.5; | ||
} | ||
|
||
if (angle >= 90.0 && angle < 180.0) { | ||
azim = angle - 180.0 + 45.0; | ||
pos_s = 0.75; | ||
} | ||
|
||
dist = sqrt(pow(tan(PI*azim/180.0),2.0) + 1.0); | ||
get_s = (tan(PI*azim/180.0) + 1.0)/8.0 + pos_s; | ||
get_t = (i.uv.y-0.5)*dist + 0.5; | ||
|
||
fixed4 col; | ||
|
||
if (i.uv.y < 0.5 - 0.5/sqrt(2.0) || i.uv.y > 0.5 + 0.5/sqrt(2.0)) { | ||
col = fixed4(0.0,0.0,0.0,0.0); | ||
} else { | ||
col = tex2D(_MainTex, float2(get_s, get_t)); | ||
} | ||
|
||
return col; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
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,21 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
[ExecuteInEditMode] | ||
public class HorizontalFieldOfView : MonoBehaviour { | ||
|
||
[Range(0,180)] | ||
public float horitzonalFieldOfView = 90; | ||
private Camera _camera; | ||
|
||
void Start () { | ||
_camera = GetComponent<Camera> (); | ||
} | ||
|
||
void Update() { | ||
float horitzonalFieldOfViewRad = Mathf.Deg2Rad * horitzonalFieldOfView; | ||
float cameraHorizontal = Mathf.Tan ( horitzonalFieldOfViewRad * 0.5f ) / _camera.aspect; | ||
float verticalFieldOfView = Mathf.Atan ( cameraHorizontal ) * 2.0f; | ||
_camera.fieldOfView = verticalFieldOfView * Mathf.Rad2Deg; | ||
} | ||
} |
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,22 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
[RequireComponent(typeof(Camera))] | ||
|
||
public class CameraFulstrumGizmo : MonoBehaviour { | ||
|
||
public virtual void OnDrawGizmos() { | ||
Matrix4x4 temp = Gizmos.matrix; | ||
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one); | ||
Gizmos.color = new Color (1.0f, 1.0f, 0.0f, 0.1f); | ||
if (GetComponent<Camera>().orthographic) { | ||
float spread = GetComponent<Camera>().farClipPlane - GetComponent<Camera>().nearClipPlane; | ||
float center = (GetComponent<Camera>().farClipPlane + GetComponent<Camera>().nearClipPlane)*0.5f; | ||
Gizmos.DrawWireCube(new Vector3(0,0,center), new Vector3(GetComponent<Camera>().orthographicSize*2*GetComponent<Camera>().aspect, GetComponent<Camera>().orthographicSize*2, spread)); | ||
} else { | ||
Gizmos.DrawFrustum(Vector3.zero, GetComponent<Camera>().fieldOfView, GetComponent<Camera>().farClipPlane, GetComponent<Camera>().nearClipPlane, GetComponent<Camera>().aspect); | ||
} | ||
Gizmos.matrix = temp; | ||
} | ||
|
||
} |
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,18 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Move : MonoBehaviour { | ||
|
||
// Use this for initialization | ||
void Start () { | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update () { | ||
Vector3 position = transform.position; | ||
position.y = Mathf.Sin (Time.time*3) * 200.0f; | ||
transform.position = position; | ||
transform.Rotate (0, 10 * Time.deltaTime, 0); | ||
} | ||
} |
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,2 @@ | ||
m_EditorVersion: 5.3.4f1 | ||
m_StandardAssetsVersion: 0 |