summaryrefslogtreecommitdiffstats
path: root/vertex.cginc
blob: 84185c6c2d4ac45279b7353c363ef6cb743b28ac (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef __VERTEX_INC
#define __VERTEX_INC

#include "vertex_deformation.hlsl"

#define FOO(x) (x)

void deform(inout float3 objPos) {
#if defined(_VERTEX_DEFORMATION_XZ_TUBE)
  {
    float t = _Vertex_Deformation_XZ_Tube_t;
    objPos = plane_to_tube(objPos.xyz, t);
  }
#endif  // _VERTEX_DEFORMATION_XZ_TUBE
#if defined(_VERTEX_DEFORMATION_YZ_TUBE)
  {
    float t = _Vertex_Deformation_YZ_Tube_t;
    objPos = plane_to_tube(objPos.yxz, t);
    objPos = objPos.yxz;
  }
#endif  // _VERTEX_DEFORMATION_YZ_TUBE
#if defined(_VERTEX_DEFORMATION_XY_TUBE)
  {
    float t = _Vertex_Deformation_XY_Tube_t;
    objPos = plane_to_tube(objPos.xzy, t);
    objPos = objPos.xzy;
  }
#endif  // _VERTEX_DEFORMATION_XY_TUBE
#if defined(_VERTEX_DEFORMATION_SEAL)
  {
    float A = _Vertex_Deformation_Seal_A;
    float k = _Vertex_Deformation_Seal_k;
    float t = _Time[3] * _Vertex_Deformation_Seal_t;
    objPos = seal(objPos.xyz, A, k, t);
  }
#endif  // _VERTEX_DEFORMATION_SEAL
#if defined(_VERTEX_DEFORMATION_SINE_WAVES)
  {
    float t = _Time[3];
    float3 amplitude = _Vertex_Deformation_Sine_Waves_Amplitude;
    float3 direction = _Vertex_Deformation_Sine_Waves_Direction;
    float3 k = _Vertex_Deformation_Sine_Waves_k;
    float3 omega = _Vertex_Deformation_Sine_Waves_omega;
    objPos = sine_wave(objPos.xyz, amplitude, direction, k, omega, t);
  }
#endif  // _VERTEX_DEFORMATION_SINE_WAVES
}

void deform_normal(float3 objPos, inout float3 objNorm, inout float3 objTan) {
#if defined(_VERTEX_DEFORMATION_XZ_TUBE)
  {
    float t = _Vertex_Deformation_XZ_Tube_t;
    plane_to_tube_normal(objPos, objNorm, objTan, t);
  }
#endif  // _VERTEX_DEFORMATION_XZ_TUBE
#if defined(_VERTEX_DEFORMATION_YZ_TUBE)
  {
    float t = _Vertex_Deformation_YZ_Tube_t;
    plane_to_tube_normal(objPos.yxz, objNorm.yxz, objTan.yxz, t);
  }
#endif  // _VERTEX_DEFORMATION_YZ_TUBE
#if defined(_VERTEX_DEFORMATION_XY_TUBE)
  {
    float t = _Vertex_Deformation_XY_Tube_t;
    plane_to_tube_normal(objPos.xzy, objNorm.xzy, objTan.xzy, t);
  }
#endif  // _VERTEX_DEFORMATION_XY_TUBE
#if defined(_VERTEX_DEFORMATION_SEAL)
  {
    float A = _Vertex_Deformation_Seal_A;
    float k = _Vertex_Deformation_Seal_k;
    float t = _Time[3] * _Vertex_Deformation_Seal_t;
    seal_normal(objPos, objNorm, objTan, A, k, t);
  }
#endif  // _VERTEX_DEFORMATION_SEAL
#if defined(_VERTEX_DEFORMATION_SINE_WAVES)
  {
    float t = _Time[3];
    float3 amplitude = _Vertex_Deformation_Sine_Waves_Amplitude;
    float3 direction = _Vertex_Deformation_Sine_Waves_Direction;
    float3 k = _Vertex_Deformation_Sine_Waves_k;
    float3 omega = _Vertex_Deformation_Sine_Waves_omega;
    sine_wave_normal(objPos, objNorm, objTan, amplitude, direction, k, omega, t);
  }
#endif  // _VERTEX_DEFORMATION_SINE_WAVES
}

void propagateObjPos(inout v2f i) {
  i.worldPos = mul(unity_ObjectToWorld, float4(i.objPos, 1));
  i.pos = UnityObjectToClipPos(i.objPos);
  i.eyeVec.xyz = i.worldPos - _WorldSpaceCameraPos;
}

#endif  // __VERTEX_INC