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

object_motion_vert.glsl « shaders « eevee « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 95cd69ba310474f3fb619634ee84062302e006c3 (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

uniform mat4 currModelMatrix;
uniform mat4 prevModelMatrix;
uniform mat4 nextModelMatrix;
uniform bool useDeform;

#ifdef HAIR
uniform samplerBuffer prvBuffer; /* RGBA32F */
uniform samplerBuffer nxtBuffer; /* RGBA32F */
#else
in vec3 pos;
in vec3 prv; /* Previous frame position. */
in vec3 nxt; /* Next frame position. */
#endif

out vec3 currWorldPos;
out vec3 prevWorldPos;
out vec3 nextWorldPos;

void main()
{
#ifdef HAIR
  bool is_persp = (ProjectionMatrix[3][3] == 0.0);
  float time, thick_time, thickness;
  vec3 tan, binor;
  vec3 wpos;

  hair_get_pos_tan_binor_time(is_persp,
                              ModelMatrixInverse,
                              ViewMatrixInverse[3].xyz,
                              ViewMatrixInverse[2].xyz,
                              wpos,
                              tan,
                              binor,
                              time,
                              thickness,
                              thick_time);

  int id = hair_get_base_id();
  vec3 pos = texelFetch(hairPointBuffer, id).point_position;
  vec3 prv = texelFetch(prvBuffer, id).point_position;
  vec3 nxt = texelFetch(nxtBuffer, id).point_position;
#endif
  prevWorldPos = (prevModelMatrix * vec4(useDeform ? prv : pos, 1.0)).xyz;
  currWorldPos = (currModelMatrix * vec4(pos, 1.0)).xyz;
  nextWorldPos = (nextModelMatrix * vec4(useDeform ? nxt : pos, 1.0)).xyz;
  /* Use jittered projmatrix to be able to match exact sample depth (depth equal test).
   * Note that currModelMatrix needs to also be equal to ModelMatrix for the samples to match. */
#ifndef HAIR
  gl_Position = ViewProjectionMatrix * vec4(currWorldPos, 1.0);
#else
  gl_Position = ViewProjectionMatrix * vec4(wpos, 1.0);
#endif
}