Skip to content

Instantly share code, notes, and snippets.

@kitasenjudesign
Last active January 16, 2022 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitasenjudesign/dcd769fc9268381a741286f51c419f08 to your computer and use it in GitHub Desktop.
Save kitasenjudesign/dcd769fc9268381a741286f51c419f08 to your computer and use it in GitHub Desktop.
CubeMap for sphere mesh (without skybox)
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