Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / avatar / src / main / rust / shaders / yuu_avatar_gles.vert
yuu_avatar_gles.vert32 lines · 1.1 KiBRaw
| 1 | #version 300 es |
| 2 | // Skinned Yuu avatar vertex shader (GLES 3.0 port of yuu_avatar.vert): |
| 3 | // 4-bone linear-blend skinning against the uBones array, then the shared |
| 4 | // view-projection. The Vulkan `clip.y` flip is removed — OpenGL NDC Y already |
| 5 | // points up — so winding stays as authored (cull off either way). |
| 6 | // NOTE(Mali): joints are vec4 (see yuu_avatar.vert) — integer attributes |
| 7 | // crash Mali drivers. |
| 8 | layout(location = 0) in vec3 inPos; |
| 9 | layout(location = 1) in vec3 inNormal; |
| 10 | layout(location = 2) in vec2 inUv; |
| 11 | layout(location = 3) in vec4 inJoints; |
| 12 | layout(location = 4) in vec4 inWeights; |
| 13 | |
| 14 | out vec3 vNormal; |
| 15 | out vec2 vUv; |
| 16 | out vec3 vWorld; |
| 17 | |
| 18 | uniform mat4 uViewProj; |
| 19 | uniform mat4 uBones[32]; |
| 20 | |
| 21 | void main() { |
| 22 | mat4 skin = |
| 23 | inWeights.x * uBones[int(inJoints.x)] + |
| 24 | inWeights.y * uBones[int(inJoints.y)] + |
| 25 | inWeights.z * uBones[int(inJoints.z)] + |
| 26 | inWeights.w * uBones[int(inJoints.w)]; |
| 27 | vec4 world = skin * vec4(inPos, 1.0); |
| 28 | vWorld = world.xyz; |
| 29 | vNormal = normalize(mat3(skin) * inNormal); |
| 30 | vUv = inUv; |
| 31 | gl_Position = uViewProj * world; |
| 32 | } |