File: stark_shadow.vertex

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (30 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (3)
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
in vec3 position1;
in vec3 position2;
in float bone1;
in float bone2;
in float boneWeight;

const int maxBones = 70;

uniform mat4 mvp;
uniform vec4 boneRotation[maxBones];
uniform vec3 bonePosition[maxBones];
uniform vec3 lightDirection;

vec3 qrot(vec4 q, vec3 v) {
	return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);
}

void main() {
	vec3 b1 = qrot(boneRotation[int(bone1)], position1) + bonePosition[int(bone1)];
	vec3 b2 = qrot(boneRotation[int(bone2)], position2) + bonePosition[int(bone2)];
	vec3 modelPosition = mix(b2, b1, boneWeight);

	// Project the modelPosition to the xz plane
	vec3 shadowPosition = modelPosition + lightDirection * (-modelPosition.y / lightDirection.y);

	// In case precision problem
	shadowPosition.y = 0.0;

	gl_Position = mvp * vec4(shadowPosition.xyz, 1.0);
}