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

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

uniform mat4 prevViewProjMatrix;
uniform mat4 currViewProjMatrix;
uniform mat4 nextViewProjMatrix;

in vec3 prevWorldPos;
in vec3 currWorldPos;
in vec3 nextWorldPos;

out vec4 outData;

void main()
{
  vec4 prev_wpos = prevViewProjMatrix * vec4(prevWorldPos, 1.0);
  vec4 curr_wpos = currViewProjMatrix * vec4(currWorldPos, 1.0);
  vec4 next_wpos = nextViewProjMatrix * vec4(nextWorldPos, 1.0);

  vec2 prev_uv = (prev_wpos.xy / prev_wpos.w);
  vec2 curr_uv = (curr_wpos.xy / curr_wpos.w);
  vec2 next_uv = (next_wpos.xy / next_wpos.w);

  outData.xy = prev_uv - curr_uv;
  outData.zw = next_uv - curr_uv;

  /* Encode to unsigned normalized 16bit texture. */
  outData = outData * 0.5 + 0.5;
}