Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 300 es
- layout(location = 0) in vec3 position;
- layout(location = 1) in vec3 normal;
- layout(location = 2) in vec2 texCoord;
- layout(location = 3) in vec3 blinking;
- layout(location = 4) in vec3 headLeft;
- layout(location = 5) in vec3 blinkingNormals;
- layout(location = 6) in vec3 headLeftNormals;
- layout(location = 7) in float index;
- out vec3 Normal;
- out vec3 FragPos;
- out vec4 ModelPos;
- out vec2 TexCoord;
- uniform mat4 model;
- uniform mat4 view;
- uniform mat4 projection;
- const int maxcount = 600;
- uniform int indicesAnimation[maxcount];
- uniform vec3 positionsAnimation[maxcount];
- uniform vec3 normalsAnimation[maxcount];
- const int indicesMouth[65] = int[](1086, 1157, 1230, 1373, 2073, 2088, 2090, 2092, 2095, 2106, 2108, 2110, 2113, 2116, 2120, 2130, 2132, 2140, 2144, 2144, 2211, 2216, 2223, 2234, 2271, 2271, 2273, 2276, 2535, 2540, 2547, 2558, 2601, 2606, 3699, 3770, 3843, 3986, 4686, 4699, 4702, 4715, 4718, 4720, 4722, 4722, 4726, 4728, 4732, 4740, 4742, 4752, 4756, 4757, 4824, 4829, 4836, 4847, 4885, 4887, 5148, 5153, 5160, 5171, 5214
- );
- uniform float amount[3];
- uniform bool animationOn;
- uniform bool isAvatar;
- flat out int mouthVertex;
- vec3 pos, norm;
- void binSearch()
- {
- int low = 0, mid, high = maxcount - 1;
- while(low <= high)
- {
- mid = (low + high) / 2;
- if (int(index) < indicesAnimation[mid])
- high = mid - 1;
- else if (int(index) > indicesAnimation[mid])
- low = mid + 1;
- else
- {
- pos += positionsAnimation[mid] * amount[0] * amount[0];
- norm += normalsAnimation[mid] * amount[0] * amount[0];
- break;
- }
- }
- }
- void main()
- {
- pos = position;
- norm = normal ;
- mouthVertex = 0;
- if(animationOn)
- {
- if(isAvatar)
- {
- pos = pos + blinking * amount[1];// + headLeft*amount[2];
- norm = normal + blinkingNormals * amount[1];
- for(int i = 1; i < 65; i += 2)
- {
- if(gl_VertexID >= (indicesMouth[i - 1]) && gl_VertexID <= (indicesMouth[i]))
- mouthVertex = 1;
- }
- }
- binSearch();
- }
- gl_Position = projection * view * model * vec4(pos, 1.0f);
- ModelPos = vec4(pos, 1.0f);
- FragPos = position;
- Normal = mat3(transpose(inverse(model))) * norm;
- TexCoord = vec2(texCoord.x, 1.0f - texCoord.y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement