Last active
January 16, 2022 02:24
-
-
Save kitasenjudesign/dcd769fc9268381a741286f51c419f08 to your computer and use it in GitHub Desktop.
CubeMap for sphere mesh (without skybox)
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
Shader "Unlit/CubeMapForSphere" | |
{ | |
Properties | |
{ | |
_Cube ("Cubemap", Cube) = "grey" {} | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" } | |
LOD 100 | |
cull front | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
// make fog work | |
#pragma multi_compile_fog | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float3 pos : TEXCOORD1; | |
float4 vertex : SV_POSITION; | |
}; | |
samplerCUBE _Cube; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.pos = v.vertex; | |
o.uv = v.uv; | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
half4 col = texCUBE (_Cube, i.pos);//pos = direction | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment