diff --git a/include/c3d/light.h b/include/c3d/light.h index e68eb29..3a477a1 100644 --- a/include/c3d/light.h +++ b/include/c3d/light.h @@ -43,6 +43,8 @@ enum C3DF_LightEnv_MtlDirty = BIT(1), C3DF_LightEnv_LCDirty = BIT(2), +#define C3DF_LightEnv_IsCP(n) BIT(18+(n)) +#define C3DF_LightEnv_IsCP_Any (0xFF<<18) #define C3DF_LightEnv_LutDirty(n) BIT(26+(n)) #define C3DF_LightEnv_LutDirtyAll (0x3F<<26) }; diff --git a/source/lightenv.c b/source/lightenv.c index 05a77d9..25eea29 100644 --- a/source/lightenv.c +++ b/source/lightenv.c @@ -40,10 +40,12 @@ static void C3Di_LightEnvSelectLayer(C3D_LightEnv* env) if (reg & (0xFF<< 8)) reg |= GPU_LC1_LUTBIT(GPU_LUT_SP); if (reg & (0xFF<<24)) reg |= GPU_LC1_LUTBIT(GPU_LUT_DA); reg = (reg >> 16) & 0xFF; - int i; - for (i = 0; i < 7; i ++) - if ((layer_enabled[i] & reg) == reg) // Check if the layer supports all LUTs we need - break; + + int i = 7; + if (!(env->flags & C3DF_LightEnv_IsCP_Any)) + for (i = 0; i < 7; i ++) + if ((layer_enabled[i] & reg) == reg) // Check if the layer supports all LUTs we need + break; env->conf.config[0] = (env->conf.config[0] &~ (0xF<<4)) | (GPU_LIGHT_ENV_LAYER_CONFIG(i)<<4); } @@ -221,6 +223,10 @@ void C3D_LightEnvLut(C3D_LightEnv* env, GPU_LIGHTLUTID lutId, GPU_LIGHTLUTINPUT env->conf.lutInput.abs |= absbit; env->flags |= C3DF_LightEnv_Dirty; + if (input == GPU_LUTINPUT_CP) + env->flags |= C3DF_LightEnv_IsCP(lutId); + else + env->flags &= ~C3DF_LightEnv_IsCP(lutId); } void C3D_LightEnvFresnel(C3D_LightEnv* env, GPU_FRESNELSEL selector)