Added WORLDSPACE_LIGHTING define (#461)

Co-authored-by: Gregory Heskett <gheskett@gmail.com>
This commit is contained in:
thecozies
2022-09-29 15:50:49 -05:00
committed by GitHub
parent ebf19af70e
commit 1ef73290d9
3 changed files with 16 additions and 2 deletions

View File

@@ -9,6 +9,14 @@
*/ */
#define GFX_POOL_SIZE 10000 #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. * Show a watermark on the title screen that reads "Made with HackerSM64", instead of the copyright message.
*/ */

View File

@@ -573,13 +573,18 @@ void setup_global_light() {
Lights1* curLight = (Lights1*)alloc_display_list(sizeof(Lights1)); Lights1* curLight = (Lights1*)alloc_display_list(sizeof(Lights1));
bcopy(&defaultLight, curLight, 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; Vec3f transformedLightDirection;
linear_mtxf_transpose_mul_vec3f(gCameraTransform, transformedLightDirection, globalLightDirection); linear_mtxf_transpose_mul_vec3f(gCameraTransform, transformedLightDirection, globalLightDirection);
curLight->l->l.dir[0] = (s8)(transformedLightDirection[0]); curLight->l->l.dir[0] = (s8)(transformedLightDirection[0]);
curLight->l->l.dir[1] = (s8)(transformedLightDirection[1]); curLight->l->l.dir[1] = (s8)(transformedLightDirection[1]);
curLight->l->l.dir[2] = (s8)(transformedLightDirection[2]); curLight->l->l.dir[2] = (s8)(transformedLightDirection[2]);
#endif
gSPSetLights1(gDisplayListHead++, (*curLight)); gSPSetLights1(gDisplayListHead++, (*curLight));
} }

View File

@@ -13,6 +13,7 @@ extern struct GraphNodeObject *gCurGraphNodeObject;
extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject; extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject;
#define gCurGraphNodeObjectNode ((struct Object *)gCurGraphNodeObject) #define gCurGraphNodeObjectNode ((struct Object *)gCurGraphNodeObject)
extern u16 gAreaUpdateCounter; extern u16 gAreaUpdateCounter;
extern Vec3f globalLightDirection;
enum AnimType { enum AnimType {
// after processing an object, the type is reset to this // after processing an object, the type is reset to this