Last active
January 25, 2021 02:46
-
-
Save partybusiness/5b41f16b851666936bd2d4a0f92260e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Shader "Unlit/CubeMaterial" | |
{ | |
Properties | |
{ | |
_Cube("Cubemap", CUBE) = "" {} | |
} | |
SubShader | |
{ | |
Tags { | |
"RenderType"="Opaque" | |
} | |
LOD 100 | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
}; | |
struct v2f | |
{ | |
float3 pos : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
samplerCUBE _Cube; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.pos = v.vertex.xyz*fixed3(-1, 1, 1); //mirror | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
fixed3 pos = normalize(i.pos); | |
fixed4 col = texCUBE(_Cube, pos); | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
This file contains hidden or 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
Shader "Unlit/Equirectangular" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_DeltaMult ("Delta Mult", float) = 0.4 | |
} | |
SubShader | |
{ | |
Tags { | |
"RenderType"="Opaque" | |
"DisableBatching"="True" | |
} | |
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; | |
float3 pos : TEXCOORD1; | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTex; | |
float _DeltaMult; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.pos = v.vertex.xyz; | |
o.uv = v.uv*_DeltaMult; //just used for deltas | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
//calculate the uvs from object vertex position | |
fixed3 pos = normalize(i.pos); | |
fixed2 uv = fixed2(-atan2(pos.x, pos.z)/ 6.28318 -0.25, asin(pos.y)/3.14159+0.5); | |
fixed4 col = tex2D(_MainTex, uv, ddx(i.uv), ddy(i.uv)); | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment