Skip to content

Commit eb8b39f

Browse files
Debug binormals (bitangents) vectors.
1 parent f2908cb commit eb8b39f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

binormals.shader

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//Debug binormals (called also bitangents)
2+
3+
Shader "Binormals"
4+
{
5+
Subshader
6+
{
7+
Pass
8+
{
9+
CGPROGRAM
10+
#pragma vertex vertex_shader
11+
#pragma fragment pixel_shader
12+
#pragma target 2.0
13+
14+
struct structure
15+
{
16+
float4 vertex : SV_POSITION;
17+
float4 color : COLOR;
18+
};
19+
20+
float3 cross(float3 a, float3 b)
21+
{
22+
return a.yzx*b.zxy-a.zxy*b.yzx;
23+
}
24+
25+
structure vertex_shader (float4 vertex:POSITION,float3 normal:NORMAL,float4 tangent:TANGENT)
26+
{
27+
structure vs;
28+
vs.vertex = UnityObjectToClipPos (vertex);
29+
float3 binormal = cross(normal,tangent.xyz)*tangent.w;
30+
vs.color = float4(binormal*0.5+0.5,1.0);
31+
return vs;
32+
}
33+
34+
float4 pixel_shader (structure ps ) : SV_TARGET
35+
{
36+
return ps.color;
37+
}
38+
39+
ENDCG
40+
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)