Don't transform the vertex again incorrectly. Optimise

This commit is contained in:
Luke Benstead 2021-04-30 07:58:57 +01:00
parent d05c5b8353
commit e67f1fb8f9
3 changed files with 8 additions and 10 deletions

View File

@ -1090,8 +1090,6 @@ static void light(SubmissionTarget* target) {
VertexExtra* extra = aligned_vector_at(target->extras, 0);
EyeSpaceData* eye_space = (EyeSpaceData*) eye_space_data->data;
mat_transform3(vertex->xyz, eye_space->xyz, target->count, sizeof(Vertex), sizeof(EyeSpaceData));
_glMatrixLoadNormal();
mat_transform_normal3(extra->nxyz, eye_space->n, target->count, sizeof(VertexExtra), sizeof(EyeSpaceData));

View File

@ -492,9 +492,9 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const uint32_t count
data = es;
for(j = 0; j < count; ++j, ++vertex, ++data) {
/* Direction to vertex in eye space */
float Vx = -data->xyz[0];
float Vy = -data->xyz[1];
float Vz = -data->xyz[2];
float Vx = -vertex->xyz[0];
float Vy = -vertex->xyz[1];
float Vz = -vertex->xyz[2];
VEC3_NORMALIZE(Vx, Vy, Vz);
const float Nx = data->n[0];
@ -506,9 +506,9 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const uint32_t count
continue;
}
float Lx = LIGHTS[i].position[0] - data->xyz[0];
float Ly = LIGHTS[i].position[1] - data->xyz[1];
float Lz = LIGHTS[i].position[2] - data->xyz[2];
float Lx = LIGHTS[i].position[0] - vertex->xyz[0];
float Ly = LIGHTS[i].position[1] - vertex->xyz[1];
float Lz = LIGHTS[i].position[2] - vertex->xyz[2];
if(LIGHTS[i].isDirectional) {
float Hx = (Lx + 0);

View File

@ -354,9 +354,9 @@ GLboolean _glIsNormalizeEnabled();
GLboolean _glRecalcFastPath();
typedef struct {
float xyz[3]; // 12 bytes
float n[3]; // 12 bytes
float finalColour[4]; //16 bytes (to 40)
float finalColour[4]; //28 bytes
uint32_t padding; // 32 bytes
} EyeSpaceData;
extern void _glPerformLighting(Vertex* vertices, EyeSpaceData *es, const uint32_t count);