Some tweaks to Spotlight support

This commit is contained in:
fincs 2017-03-30 23:42:29 +02:00
parent 370e938520
commit 7354976bca
2 changed files with 7 additions and 0 deletions

View File

@ -21,9 +21,15 @@ static inline float quadratic_dist_attn(float dist, float linear, float quad)
return 1.0f / (1.0f + linear*dist + quad*dist*dist);
}
static inline float spot_step(float angle, float cutoff)
{
return angle >= cutoff ? 1.0f : 0.0f;
}
void LightLut_FromArray(C3D_LightLut* lut, float* data);
void LightLut_FromFunc(C3D_LightLut* lut, C3D_LightLutFunc func, float param, bool negative);
void LightLutDA_Create(C3D_LightLutDA* lut, C3D_LightLutFuncDA func, float from, float to, float arg0, float arg1);
#define LightLut_Phong(lut, shininess) LightLut_FromFunc((lut), powf, (shininess), false)
#define LightLut_Spotlight(lut, angle) LightLut_FromFunc((lut), spot_step, cosf(angle), true)
#define LightLutDA_Quadratic(lut, from, to, linear, quad) LightLutDA_Create((lut), quadratic_dist_attn, (from), (to), (linear), (quad))

View File

@ -155,6 +155,7 @@ void C3D_LightEnvInit(C3D_LightEnv* env)
env->flags = C3DF_LightEnv_Dirty;
env->conf.config[0] = (4<<8) | BIT(27) | BIT(31);
env->conf.config[1] = ~0;
env->conf.lutInput.select = GPU_LIGHTLUTINPUT(GPU_LUT_SP, GPU_LUTINPUT_SP);
env->conf.lutInput.abs = 0x2222222;
}