Skip to content

Commit 3ed51a5

Browse files
Volumetric light scattering demo
1 parent 06dce15 commit 3ed51a5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

volumetric_lighting.shader

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Shader "Volumetric Lighting"
2+
{
3+
Properties
4+
{
5+
pattern ("Texture", 2D) = "white" {}
6+
}
7+
Subshader
8+
{
9+
Pass
10+
{
11+
CGPROGRAM
12+
#pragma vertex vertex_shader
13+
#pragma fragment pixel_shader
14+
#pragma target 3.0
15+
16+
sampler2D pattern;
17+
18+
struct structure
19+
{
20+
float4 vertex : SV_POSITION;
21+
float2 uv : TEXCOORD0;
22+
};
23+
24+
structure vertex_shader (float4 vertex:POSITION, float2 uv:TEXCOORD0)
25+
{
26+
structure vs;
27+
vs.vertex = UnityObjectToClipPos(vertex);
28+
vs.uv = uv;
29+
return vs;
30+
}
31+
32+
float4 pixel_shader (structure ps) : COLOR
33+
{
34+
float2 uv = float2(2.0*ps.uv.xy-1.0);
35+
float color = 0.0;
36+
for(int i=0;i<192;++i)
37+
{
38+
float2 p=(uv*asin(dot(uv,uv)*float(i)*0.01)/dot(uv,uv));
39+
p.x-=_Time.g*0.5;
40+
color+=tex2Dlod(pattern,float4(p*0.2,0.0,0.0)).r*0.01;
41+
}
42+
return float4(color,0.0,0.0,1.0);
43+
}
44+
ENDCG
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)