@block vptr in vec3 a_pos; in vec2 a_uv; in vec4 a_norm; out vec2 tex_coords; out vec3 normal; uniform vs_p { uniform mat4 vp; }; uniform vmodel { uniform mat4 model; }; @end @vs vs @include_block vptr in vec4 a_bone; in vec4 a_weight; uniform skinv { uniform mat4 bones[50]; }; void main() { mat4 tt = vp; mat4 mm = model; mat4 skin = bones[int(a_bone.x)] * a_weight.x; skin += bones[int(a_bone.y)] * a_weight.y; skin += bones[int(a_bone.z)] * a_weight.z; skin += bones[int(a_bone.w)] * a_weight.w; mat4 skinm = mm * skin; gl_Position = tt * skinm * vec4(a_pos,1.0); tex_coords = a_uv; normal = (skinm * vec4(a_norm.xyz*2-1,0)).xyz; } @end @vs vs_st @include_block vptr void main() { gl_Position = vp * model * vec4(a_pos,1.0); tex_coords = a_uv; normal = (model * vec4(a_norm.xyz*2-1,0)).xyz; } @end @fs fs in vec2 tex_coords; in vec3 normal; out vec4 color; uniform texture2D diffuse; uniform sampler smp; uniform lightf { vec4 ambient; }; void main() { vec3 lightDir = normalize(vec3(0.5f, 0.5f, 1.0f)); float diff = max(dot(normal, lightDir), 0.0f); color = texture(sampler2D(diffuse,smp),tex_coords) * ambient; } @end @program unlit vs fs @program unlit_st vs_st fs