WIP Skinned Shader

This commit is contained in:
Jay 2020-07-29 17:56:30 +01:00
parent 068b85d5f3
commit 376831e2bb
3 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,12 @@
$input v_normal, v_colour, v_position, v_pbr
#include <teverse.sh>
uniform vec4 uniformCameraPosition;
void main()
{
gl_FragData[0] = vec4(v_colour.xyz, v_pbr.x);
gl_FragData[1] = vec4(v_normal, v_pbr.y);
//gl_FragData[2] = vec4(v_position, 0.0);
}

View File

@ -0,0 +1,10 @@
vec3 v_view : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
vec3 v_position : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
vec4 v_colour : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_pbr : TEXCOORD4 = vec4(0.0, 0.0, 0.0, 0.0);
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
vec3 a_position : POSITION;
vec4 a_normal : NORMAL;
vec4 a_weight : BLENDWEIGHT;
vec4 a_indices : BLENDINDICES;

34
shaders/skinned/vertex.sc Normal file
View File

@ -0,0 +1,34 @@
$input a_position, a_normal, a_weight, a_indices
$output v_normal, v_colour, v_position, v_pbr
#include <teverse.sh>
#include <teverse_compute.sh>
uniform mat3 normalMatrix;
uniform vec4 colour;
uniform vec4 pbr;
uniform mat4 jointMatrix[90];
void main()
{
// metalness, roughness, 0, 0
v_pbr = pbr;
mat4 model = (
a_weight.x * jointMatrix[int(a_indices.x)] +
a_weight.y * jointMatrix[int(a_indices.y)] +
a_weight.z * jointMatrix[int(a_indices.z)] +
a_weight.w * jointMatrix[int(a_indices.w)]
);
vec4 wpos = mul(model, vec4(a_position, 1.0));
gl_Position = mul(u_modelViewProj, wpos);
//gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0));
vec3 normal = a_normal.xyz * 2.0 - 1.0;
vec3 wnormal = instMul(normalMatrix, normal.xyz);
v_normal = encodeNormalUint(normalize(wnormal.xyz));
v_colour = colour;
v_position = gl_Position.xyz;
}