1
2#pragma BLENDER_REQUIRE(common_hair_lib.glsl)
3#pragma BLENDER_REQUIRE(common_view_lib.glsl)
4#pragma BLENDER_REQUIRE(surface_lib.glsl)
5
6#ifndef HAIR_SHADER
7in vec3 pos;
8in vec3 nor;
9#endif
10
11RESOURCE_ID_VARYING
12
13void main()
14{
15  GPU_INTEL_VERTEX_SHADER_WORKAROUND
16
17  PASS_RESOURCE_ID
18
19#ifdef HAIR_SHADER
20  hairStrandID = hair_get_strand_id();
21  vec3 pos, binor;
22  hair_get_pos_tan_binor_time((ProjectionMatrix[3][3] == 0.0),
23                              ModelMatrixInverse,
24                              ViewMatrixInverse[3].xyz,
25                              ViewMatrixInverse[2].xyz,
26                              pos,
27                              hairTangent,
28                              binor,
29                              hairTime,
30                              hairThickness,
31                              hairThickTime);
32  worldNormal = cross(hairTangent, binor);
33  vec3 world_pos = pos;
34#else
35  vec3 world_pos = point_object_to_world(pos);
36#endif
37
38  gl_Position = point_world_to_ndc(world_pos);
39
40  /* Used for planar reflections */
41  gl_ClipDistance[0] = dot(vec4(world_pos, 1.0), clipPlanes[0]);
42
43#ifdef MESH_SHADER
44  worldPosition = world_pos;
45  viewPosition = point_world_to_view(worldPosition);
46
47#  ifndef HAIR_SHADER
48  worldNormal = normalize(normal_object_to_world(nor));
49#  endif
50
51  /* No need to normalize since this is just a rotation. */
52  viewNormal = normal_world_to_view(worldNormal);
53#  ifdef USE_ATTR
54#    ifdef HAIR_SHADER
55  pos = hair_get_strand_pos();
56#    endif
57  pass_attr(pos, NormalMatrix, ModelMatrixInverse);
58#  endif
59#endif
60}
61