Skip to content

Commit 9f90238

Browse files
Procedural skybox minimal example
1 parent 7f05101 commit 9f90238

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ProceduralSkybox.shader

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Shader "Procedural Skybox"
2+
{
3+
Subshader
4+
{
5+
Pass
6+
{
7+
CGPROGRAM
8+
#pragma vertex SetVertexShader
9+
#pragma fragment SetPixelShader
10+
11+
void SetVertexShader (inout float4 Vertex:POSITION, out float3 Point:TEXCOORD0)
12+
{
13+
Point = mul(unity_ObjectToWorld, Vertex); // World Space coordinate
14+
Vertex = UnityObjectToClipPos (Vertex); // Screen Space coordinate
15+
}
16+
17+
void SetPixelShader (float4 Vertex:POSITION, float3 Point:TEXCOORD0, out float4 Color:SV_TARGET)
18+
{
19+
float3 Direction = normalize(Point - _WorldSpaceCameraPos); //Direction vector
20+
Color = (Direction.y>0.0) ? Direction.yyyy : 0; //Pixel color
21+
}
22+
23+
ENDCG
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)