add support for skeletal animation
This commit is contained in:
BIN
Sandbox/assets/models/Plane1m.fbx
Normal file
BIN
Sandbox/assets/models/Plane1m.fbx
Normal file
Binary file not shown.
17
Sandbox/assets/models/Plane1m.obj
Normal file
17
Sandbox/assets/models/Plane1m.obj
Normal file
@ -0,0 +1,17 @@
|
||||
# Blender v2.80 (sub 75) OBJ File: 'Plane1m.blend'
|
||||
# www.blender.org
|
||||
mtllib Plane1m.mtl
|
||||
o Plane
|
||||
v -0.500000 0.000000 0.500000
|
||||
v 0.500000 0.000000 0.500000
|
||||
v -0.500000 0.000000 -0.500000
|
||||
v 0.500000 0.000000 -0.500000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.000000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 1.000000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
usemtl None
|
||||
s off
|
||||
f 2/1/1 3/2/1 1/3/1
|
||||
f 2/1/1 4/4/1 3/2/1
|
||||
BIN
Sandbox/assets/models/Sphere1m.fbx
Normal file
BIN
Sandbox/assets/models/Sphere1m.fbx
Normal file
Binary file not shown.
Binary file not shown.
BIN
Sandbox/assets/models/m1911/m1911.fbx
Normal file
BIN
Sandbox/assets/models/m1911/m1911.fbx
Normal file
Binary file not shown.
BIN
Sandbox/assets/models/m1911/m1911_color.png
Normal file
BIN
Sandbox/assets/models/m1911/m1911_color.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 MiB |
BIN
Sandbox/assets/models/m1911/m1911_metalness.png
Normal file
BIN
Sandbox/assets/models/m1911/m1911_metalness.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 MiB |
BIN
Sandbox/assets/models/m1911/m1911_normal.png
Normal file
BIN
Sandbox/assets/models/m1911/m1911_normal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
BIN
Sandbox/assets/models/m1911/m1911_roughness.png
Normal file
BIN
Sandbox/assets/models/m1911/m1911_roughness.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 MiB |
50
Sandbox/assets/shaders/Grid.glsl
Normal file
50
Sandbox/assets/shaders/Grid.glsl
Normal file
@ -0,0 +1,50 @@
|
||||
// Simple Texture Shader
|
||||
|
||||
#type vertex
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
layout(location = 4) in vec2 a_TexCoord;
|
||||
|
||||
uniform mat4 u_MVP;
|
||||
|
||||
out vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 position = u_MVP * vec4(a_Position, 1.0);
|
||||
gl_Position = position;
|
||||
|
||||
v_TexCoord = a_TexCoord;
|
||||
}
|
||||
|
||||
#type fragment
|
||||
#version 430
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
uniform sampler2D u_Texture;
|
||||
uniform float u_Scale;
|
||||
uniform float u_Res;
|
||||
|
||||
in vec2 v_TexCoord;
|
||||
|
||||
/*void main()
|
||||
{
|
||||
color = texture(u_Texture, v_TexCoord * 8.0);
|
||||
}*/
|
||||
|
||||
float grid(vec2 st, float res)
|
||||
{
|
||||
vec2 grid = fract(st);
|
||||
return step(res, grid.x) * step(res, grid.y);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float scale = u_Scale;
|
||||
float resolution = u_Res;
|
||||
|
||||
float x = grid(v_TexCoord * scale, resolution);
|
||||
color = vec4(vec3(0.2), 0.5) * (1.0 - x);
|
||||
}
|
||||
@ -18,25 +18,41 @@ layout(location = 2) in vec3 a_Tangent;
|
||||
layout(location = 3) in vec3 a_Binormal;
|
||||
layout(location = 4) in vec2 a_TexCoord;
|
||||
|
||||
layout(location = 5) in ivec4 a_BoneIndices;
|
||||
layout(location = 6) in vec4 a_BoneWeights;
|
||||
|
||||
uniform mat4 u_ViewProjectionMatrix;
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
const int MAX_BONES = 100;
|
||||
uniform mat4 u_BoneTransforms[100];
|
||||
|
||||
out VertexOutput
|
||||
{
|
||||
vec3 WorldPosition;
|
||||
vec3 Normal;
|
||||
vec2 TexCoord;
|
||||
mat3 WorldNormals;
|
||||
vec3 Binormal;
|
||||
} vs_Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
vs_Output.WorldPosition = vec3(mat4(u_ModelMatrix) * vec4(a_Position, 1.0));
|
||||
vs_Output.Normal = a_Normal;
|
||||
mat4 boneTransform = u_BoneTransforms[a_BoneIndices[0]] * a_BoneWeights[0];
|
||||
boneTransform += u_BoneTransforms[a_BoneIndices[1]] * a_BoneWeights[1];
|
||||
boneTransform += u_BoneTransforms[a_BoneIndices[2]] * a_BoneWeights[2];
|
||||
boneTransform += u_BoneTransforms[a_BoneIndices[3]] * a_BoneWeights[3];
|
||||
|
||||
vec4 localPosition = boneTransform * vec4(a_Position, 1.0);
|
||||
|
||||
vs_Output.WorldPosition = vec3(u_ModelMatrix * boneTransform * vec4(a_Position, 1.0));
|
||||
vs_Output.Normal = mat3(boneTransform) * a_Normal;
|
||||
vs_Output.TexCoord = vec2(a_TexCoord.x, 1.0 - a_TexCoord.y);
|
||||
vs_Output.WorldNormals = mat3(u_ModelMatrix) * mat3(a_Tangent, a_Binormal, a_Normal);
|
||||
vs_Output.Binormal = mat3(boneTransform) * a_Binormal;
|
||||
|
||||
gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);
|
||||
//gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);
|
||||
gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * localPosition;
|
||||
}
|
||||
|
||||
#type fragment
|
||||
@ -62,6 +78,7 @@ in VertexOutput
|
||||
vec3 Normal;
|
||||
vec2 TexCoord;
|
||||
mat3 WorldNormals;
|
||||
vec3 Binormal;
|
||||
} vs_Input;
|
||||
|
||||
layout(location=0) out vec4 color;
|
||||
|
||||
Reference in New Issue
Block a user