You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
1.8 KiB

Shader "Kinect/OpticalFlowDebugShader"
{
Properties
{
_Size("Size", Range(0, 100)) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
//Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma geometry geom
#pragma fragment frag
#include "UnityCG.cginc"
#ifdef SHADER_API_D3D11
StructuredBuffer<float4> KinectPositionBuffer;
StructuredBuffer<float4> KinectVelocityBuffer;
#endif
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2g
{
//float4 vertex : SV_POSITION;
//float2 uv : TEXCOORD0;
uint id : BLENDINDICES;
//UNITY_FOG_COORDS(1)
};
struct g2f
{
float4 vertex : SV_POSITION;
float3 color : COLOR;
};
float _Size;
float colorize;
v2g vert(appdata_base v, uint vid : SV_VertexID)
{
v2g o = (v2g)0;
o.id = vid;
return o;
}
[maxvertexcount(2)]
void geom(point v2g input[1], inout LineStream<g2f> OutputStream)
{
#ifdef SHADER_API_D3D11
float4 position = KinectPositionBuffer[input[0].id];
float4 velocity = KinectVelocityBuffer[input[0].id];
#else
float4 position = float4(0, 0, 0, 1);
float4 velocity = float4(0, 0, 0, 0);
#endif
float3 c0 = float3(0, 1, 0);
float3 c1 = float3(1, 0, 0);
c0 = float3(237, 210, 152) / 255;
c1 = float3(3, 46, 82) / 255;
g2f o = (g2f)0;
o.vertex = UnityObjectToClipPos(position.xyz);
o.color = lerp(float3(0, 0, 0), c0, colorize);
OutputStream.Append(o);
o.vertex = UnityObjectToClipPos(position.xyz - velocity.xyz * _Size);
o.color = lerp(float3(0, 0, 0), c1, colorize);
OutputStream.Append(o);
OutputStream.RestartStrip();
}
fixed4 frag (g2f i) : SV_Target
{
fixed4 col = float4(i.color, 1.0f);
return col;
}
ENDCG
}
}
}