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
|
// Normals
float3 CreateBinormal(float3 normal, float3 tangent, float binormalSign)
{
return cross(normal, tangent.xyz) *
(binormalSign * unity_WorldTransformParams.w);
}
bool IsInMirror()
{
return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f;
}
// Camera
float3 getCameraPosition()
{
#ifdef USING_STEREO_MATRICES
return lerp(unity_StereoWorldSpaceCameraPos[0], unity_StereoWorldSpaceCameraPos[1], 0.5);
#endif
return _WorldSpaceCameraPos;
}
float3 getCameraForward()
{
#if UNITY_SINGLE_PASS_STEREO
float3 p1 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 1, 1));
float3 p2 = mul(unity_StereoCameraToWorld[0], float4(0, 0, 0, 1));
#else
float3 p1 = mul(unity_CameraToWorld, float4(0, 0, 1, 1));
float3 p2 = mul(unity_CameraToWorld, float4(0, 0, 0, 1));
#endif
return normalize(p2 - p1);
}
float3 grayscale_vector_node()
{
return float3(0, 0.3823529, 0.01845836);
}
float3 grayscale_for_light()
{
return float3(0.298912, 0.586611, 0.114478);
}
|