-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2b9884
commit 14d5f68
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# UV Sky | ||
A 360° video skybox shader. | ||
|
||
## Download | ||
Download the shader [here](UVSky.shader) and drag it into a shaders folder. | ||
|
||
## How To Use | ||
Create a new material, use the shader select to select `Synergiance/Skybox/UV Sky`, drag your desired texture into the texture slot. Use the slider below to adjust the orientation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Shader "Synergiance/Skybox/UV Sky" | ||
{ | ||
Properties { | ||
[NoScaleOffset] _MainTex ("Texture", 2D) = "default" {} | ||
_Rotation ("Rotation (Degrees)", Range(-180, 180)) = 0 | ||
} | ||
SubShader | ||
{ | ||
Tags { "RenderType"="Opaque" } | ||
LOD 100 | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
|
||
#define ONE_OVER_PI 0.31830988618 | ||
|
||
#if defined(USING_STEREO_MATRICES) | ||
#define _ActualWorldSpaceCameraPos unity_StereoWorldSpaceCameraPos[unity_StereoEyeIndex] | ||
#else | ||
#define _ActualWorldSpaceCameraPos _WorldSpaceCameraPos | ||
#endif | ||
|
||
struct appdata { | ||
float4 vertex : POSITION; | ||
}; | ||
|
||
struct v2f { | ||
float4 vertex : SV_POSITION; | ||
float3 worldPos : TEXCOORD0; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float _Rotation; | ||
|
||
v2f vert (appdata v) { | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; | ||
return o; | ||
} | ||
|
||
fixed4 frag (v2f i) : SV_Target { | ||
float3 viewDir = i.worldPos.xyz - _ActualWorldSpaceCameraPos.xyz; | ||
float longitude = atan2(viewDir.x, viewDir.z); | ||
float latitude = atan2(length(viewDir.xz), viewDir.y); | ||
float2 uv = float2(longitude * 0.5, latitude) * ONE_OVER_PI; | ||
uv.x += _Rotation / 360; | ||
fixed4 col = tex2D(_MainTex, uv); | ||
return col; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |