diff --git a/include/config/config_graphics.h b/include/config/config_graphics.h index 34efdeb0..f58b8266 100644 --- a/include/config/config_graphics.h +++ b/include/config/config_graphics.h @@ -9,6 +9,14 @@ */ #define GFX_POOL_SIZE 10000 +/** + * Causes the global light direction to be in world space, + * this allows you to have a singular light source that doesn't change with the camera's rotation. + * By modifying `globalLightDirection`, you can choose the direction that points TOWARDS the light, + * but keep in mind that this direction should be normalized to roughly ~127 if changed. + */ +// #define WORLDSPACE_LIGHTING + /** * Show a watermark on the title screen that reads "Made with HackerSM64", instead of the copyright message. */ diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index 9b562e92..e5208d47 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -573,13 +573,18 @@ void setup_global_light() { Lights1* curLight = (Lights1*)alloc_display_list(sizeof(Lights1)); bcopy(&defaultLight, curLight, sizeof(Lights1)); +#ifdef WORLDSPACE_LIGHTING + curLight->l->l.dir[0] = (s8)(globalLightDirection[0]); + curLight->l->l.dir[1] = (s8)(globalLightDirection[1]); + curLight->l->l.dir[2] = (s8)(globalLightDirection[2]); +#else Vec3f transformedLightDirection; - linear_mtxf_transpose_mul_vec3f(gCameraTransform, transformedLightDirection, globalLightDirection); - curLight->l->l.dir[0] = (s8)(transformedLightDirection[0]); curLight->l->l.dir[1] = (s8)(transformedLightDirection[1]); curLight->l->l.dir[2] = (s8)(transformedLightDirection[2]); +#endif + gSPSetLights1(gDisplayListHead++, (*curLight)); } diff --git a/src/game/rendering_graph_node.h b/src/game/rendering_graph_node.h index b7bce291..f65778c1 100644 --- a/src/game/rendering_graph_node.h +++ b/src/game/rendering_graph_node.h @@ -13,6 +13,7 @@ extern struct GraphNodeObject *gCurGraphNodeObject; extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject; #define gCurGraphNodeObjectNode ((struct Object *)gCurGraphNodeObject) extern u16 gAreaUpdateCounter; +extern Vec3f globalLightDirection; enum AnimType { // after processing an object, the type is reset to this