/* * 3D Engine * light.c: * Based on pikuma.com 3D software renderer in C * Copyright (c) 2021 986-Studio. All rights reserved. * * Created by Manoƫl Trapier on 06/03/2021. */ #include #include #include void createLight(light_t *light, vec3_t direction) { light->direction = direction; vec3Normalize(&light->direction); } colour_t applyLight(colour_t c, double lightLevel) { if (lightLevel < 0) { lightLevel = 0; } if (lightLevel > 1) { lightLevel = 1; } uint8_t r = round(((c >> 16) & 0xFF) * lightLevel); uint8_t g = round(((c >> 8) & 0xFF) * lightLevel); uint8_t b = round(((c ) & 0xFF) * lightLevel); return MAKE_RGB(r, g, b); }