Animate normals; Use material color;

This commit is contained in:
bjorn 2022-07-03 19:20:30 -07:00
parent d088c5471d
commit 0d23d10e43
4 changed files with 9 additions and 3 deletions

View File

@ -47,4 +47,10 @@ void main() {
vertexOut[vertexIndex].x = skinned.x;
vertexOut[vertexIndex].y = skinned.y;
vertexOut[vertexIndex].z = skinned.z;
vec3 normal = vec3(vertexIn[vertexIndex].nx, vertexIn[vertexIndex].ny, vertexIn[vertexIndex].nz);
vec3 skinnedNormal = mat3(matrix) * normal;
vertexOut[vertexIndex].nx = skinnedNormal.x;
vertexOut[vertexIndex].ny = skinnedNormal.y;
vertexOut[vertexIndex].nz = skinnedNormal.z;
}

View File

@ -108,5 +108,5 @@ layout(location = 11) in vec2 FragUV;
#define WorldFromLocal (Transform)
#define DefaultPosition (ClipFromLocal * VertexPosition)
#define DefaultColor (FragColor)
#define DefaultColor (FragColor * texture(sampler2D(Texture, Sampler), FragUV) * Material.color)
#endif

View File

@ -5,5 +5,5 @@
#include "lovr.glsl"
void main() {
PixelColors[0] = FragColor * texture(sampler2D(Texture, Sampler), FragUV);
PixelColors[0] = FragColor * texture(sampler2D(Texture, Sampler), FragUV) * Material.color;
}

View File

@ -4213,7 +4213,7 @@ static void renderNode(Pass* pass, Model* model, uint32_t index, bool recurse, u
for (uint32_t i = 0; i < node->primitiveCount; i++) {
Draw draw = model->draws[node->primitiveIndex + i];
draw.transform = globalTransform;
if (node->skin == ~0u) draw.transform = globalTransform;
draw.instances = instances;
lovrPassDraw(pass, &draw);
}