-
Notifications
You must be signed in to change notification settings - Fork 4
/
sh_PCloud_Pass.shader
50 lines (45 loc) · 1.06 KB
/
sh_PCloud_Pass.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Shader "ParticleCloud/Pass"
{
Properties
{
[NoScaleOffset]
_Buffer ("Positions", 2D) = "gray" {}
_Str ("Strength", Range(-5.0, 5.0)) = 1.0
}
SubShader
{
Tags { "Queue"="Overlay+1000" "IgnoreProjector"="True" "RenderType"="Overlay" "PreviewType"="Plane" "DisableBatching"="True"}
Blend Off
//Cull Off
ZWrite On
ZTest Always
ColorMask RGBA
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 4.6
#include "UnityCG.cginc"
#include "PCloud_Util.cginc"
Texture2D<float4> _Buffer;
uniform float _Str;
//--- Vertex shader ---//
float4 vert(float4 vertex : POSITION) : SV_Position
{
// TODO place vertices at camera near clip
if (_ProjectionParams.y != CAMCLIP) // hide other cameras players
return float4(0,0,0,0);
return UnityObjectToClipPos(vertex);
}
//--- Fragment shader ---//
float4 frag (float4 i : SV_Position) : SV_Target
{
if ((i.x+i.y) <= 1.1) // Store camera
return EncodeColor(float4(_WorldSpaceCameraPos, _Str));
return _Buffer.Load(i.xyz); // Pass-through
}
ENDCG
}
}
}