REVIEWED: Shaders formating to follow raylib code conventions
This commit is contained in:
parent
8dae39fbda
commit
9b598f6bcf
1 changed files with 806 additions and 806 deletions
|
|
@ -27,15 +27,15 @@ mat3 inverse(mat3 m)
|
|||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
|
||||
|
||||
float b01 = a22 * a11 - a12 * a21;
|
||||
float b11 = -a22 * a10 + a12 * a20;
|
||||
float b21 = a21 * a10 - a11 * a20;
|
||||
float b01 = a22*a11 - a12*a21;
|
||||
float b11 = -a22*a10 + a12*a20;
|
||||
float b21 = a21*a10 - a11*a20;
|
||||
|
||||
float det = a00 * b01 + a01 * b11 + a02 * b21;
|
||||
float det = a00*b01 + a01*b11 + a02*b21;
|
||||
|
||||
return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
|
||||
b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
|
||||
b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
|
||||
return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
|
||||
b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
|
||||
b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
|
||||
}
|
||||
|
||||
// https://github.com/glslify/glsl-transpose
|
||||
|
|
@ -49,21 +49,21 @@ mat3 transpose(mat3 m)
|
|||
void main()
|
||||
{
|
||||
// Compute binormal from vertex normal and tangent. W component is the tangent handedness
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz) * vertexTangent.w;
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent.xyz)*vertexTangent.w;
|
||||
|
||||
// Compute fragment normal based on normal transformations
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
|
||||
// Compute fragment position based on model transformations
|
||||
fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
|
||||
//Create TBN matrix for transforming the normal map values from tangent-space to world-space
|
||||
fragNormal = normalize(normalMatrix * vertexNormal);
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
|
||||
vec3 fragTangent = normalize(normalMatrix * vertexTangent.xyz);
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal) * fragNormal);
|
||||
vec3 fragTangent = normalize(normalMatrix*vertexTangent.xyz);
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
|
||||
|
||||
vec3 fragBinormal = normalize(normalMatrix * vertexBinormal);
|
||||
vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
|
||||
fragBinormal = cross(fragNormal, fragTangent);
|
||||
|
||||
TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
|
||||
|
|
@ -72,5 +72,5 @@ void main()
|
|||
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = mvp * vec4(vertexPosition, 1.0);
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue