Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_material_vector_math.glsl « material « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ad5d4232de94c73264a2cdc919939f848a0a3ba (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
void vector_math_add(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a + b;
}

void vector_math_subtract(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a - b;
}

void vector_math_multiply(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a * b;
}

void vector_math_divide(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = safe_divide(a, b);
}

void vector_math_cross(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = cross(a, b);
}

void vector_math_project(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  float lenSquared = dot(b, b);
  outVector = (lenSquared != 0.0) ? (dot(a, b) / lenSquared) * b : vec3(0.0);
}

void vector_math_reflect(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = reflect(a, normalize(b));
}

void vector_math_dot(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outValue = dot(a, b);
}

void vector_math_distance(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outValue = distance(a, b);
}

void vector_math_length(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outValue = length(a);
}

void vector_math_scale(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a * scale;
}

void vector_math_normalize(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a;
  /* Safe version of normalize(a). */
  float lenSquared = dot(a, a);
  if (lenSquared > 0.0) {
    outVector *= inversesqrt(lenSquared);
  }
}

void vector_math_snap(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = floor(safe_divide(a, b)) * b;
}

void vector_math_floor(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = floor(a);
}

void vector_math_ceil(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = ceil(a);
}

void vector_math_modulo(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = compatible_fmod(a, b);
}

void vector_math_wrap(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = wrap(a, b, c);
}

void vector_math_fraction(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = fract(a);
}

void vector_math_absolute(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = abs(a);
}

void vector_math_minimum(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = min(a, b);
}

void vector_math_maximum(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = max(a, b);
}

void vector_math_sine(vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = sin(a);
}

void vector_math_cosine(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = cos(a);
}

void vector_math_tangent(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = tan(a);
}

void vector_math_refract(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = refract(a, normalize(b), scale);
}

void vector_math_faceforward(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = faceforward(a, b, c);
}

void vector_math_multiply_add(
    vec3 a, vec3 b, vec3 c, float scale, out vec3 outVector, out float outValue)
{
  outVector = a * b + c;
}