@@ -430,7 +430,7 @@ impl Light {
430430 }
431431 }
432432
433- /// Sets the spotlight direction of the light (relatively to the light's source [position](set_position)).
433+ /// Sets the spotlight direction of the light (relatively to the light's source [position](Light:: set_position)).
434434 #[ doc( alias = "C3D_LightSpotDir" ) ]
435435 pub fn set_spotlight_direction ( self : Pin < & mut Self > , direction : FVec3 ) {
436436 unsafe {
@@ -636,6 +636,21 @@ pub enum LutInput {
636636 ViewHalf = ctru_sys:: GPU_LUTINPUT_VH ,
637637}
638638
639+ impl TryFrom < u8 > for LutInput {
640+ type Error = String ;
641+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
642+ match value {
643+ ctru_sys:: GPU_LUTINPUT_NH => Ok ( Self :: NormalHalf ) ,
644+ ctru_sys:: GPU_LUTINPUT_VH => Ok ( Self :: ViewHalf ) ,
645+ ctru_sys:: GPU_LUTINPUT_NV => Ok ( Self :: NormalView ) ,
646+ ctru_sys:: GPU_LUTINPUT_LN => Ok ( Self :: LightNormal ) ,
647+ ctru_sys:: GPU_LUTINPUT_SP => Ok ( Self :: LightSpotLight ) ,
648+ ctru_sys:: GPU_LUTINPUT_CP => Ok ( Self :: CosPhi ) ,
649+ _ => Err ( "invalid value for LutInput" . to_string ( ) ) ,
650+ }
651+ }
652+ }
653+
639654/// Identifier/index for the various LUTs associated to a [`LightEnv`].
640655///
641656/// # Notes
@@ -664,6 +679,23 @@ pub enum LutId {
664679 DistanceAttenuation = ctru_sys:: GPU_LUT_DA ,
665680}
666681
682+ impl TryFrom < u8 > for LutId {
683+ type Error = String ;
684+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
685+ match value {
686+ ctru_sys:: GPU_LUT_D0 => Ok ( Self :: D0 ) ,
687+ ctru_sys:: GPU_LUT_D1 => Ok ( Self :: D1 ) ,
688+ ctru_sys:: GPU_LUT_SP => Ok ( Self :: Spotlight ) ,
689+ ctru_sys:: GPU_LUT_FR => Ok ( Self :: Fresnel ) ,
690+ ctru_sys:: GPU_LUT_RB => Ok ( Self :: ReflectBlue ) ,
691+ ctru_sys:: GPU_LUT_RG => Ok ( Self :: ReflectGreen ) ,
692+ ctru_sys:: GPU_LUT_RR => Ok ( Self :: ReflectRed ) ,
693+ ctru_sys:: GPU_LUT_DA => Ok ( Self :: DistanceAttenuation ) ,
694+ _ => Err ( "invalid value for LutId" . to_string ( ) ) ,
695+ }
696+ }
697+ }
698+
667699#[ doc( alias = "GPU_FRESNELSEL" ) ]
668700#[ derive( Clone , Copy , Hash , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
669701#[ repr( u8 ) ]
@@ -678,6 +710,94 @@ pub enum FresnelSelector {
678710 Both = ctru_sys:: GPU_PRI_SEC_ALPHA_FRESNEL ,
679711}
680712
713+ impl TryFrom < u8 > for FresnelSelector {
714+ type Error = String ;
715+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
716+ match value {
717+ ctru_sys:: GPU_NO_FRESNEL => Ok ( Self :: None ) ,
718+ ctru_sys:: GPU_PRI_ALPHA_FRESNEL => Ok ( Self :: PrimaryAlpha ) ,
719+ ctru_sys:: GPU_SEC_ALPHA_FRESNEL => Ok ( Self :: SecondaryAlpha ) ,
720+ ctru_sys:: GPU_PRI_SEC_ALPHA_FRESNEL => Ok ( Self :: Both ) ,
721+ _ => Err ( "invalid value for FresnelSelector" . to_string ( ) ) ,
722+ }
723+ }
724+ }
725+
726+ /// LUT scaling factors.
727+ #[ repr( u8 ) ]
728+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
729+ #[ doc( alias = "GPU_LIGHTLUTSCALER" ) ]
730+ pub enum LutScale {
731+ /// 1x scale.
732+ #[ doc( alias = "GPU_LUTSCALER_1x" ) ]
733+ OneX = ctru_sys:: GPU_LUTSCALER_1x ,
734+
735+ /// 2x scale.
736+ #[ doc( alias = "GPU_LUTSCALER_2x" ) ]
737+ TwoX = ctru_sys:: GPU_LUTSCALER_2x ,
738+
739+ /// 4x scale.
740+ #[ doc( alias = "GPU_LUTSCALER_4x" ) ]
741+ FourX = ctru_sys:: GPU_LUTSCALER_4x ,
742+
743+ /// 8x scale.
744+ #[ doc( alias = "GPU_LUTSCALER_8x" ) ]
745+ EightX = ctru_sys:: GPU_LUTSCALER_8x ,
746+
747+ /// 0.25x scale.
748+ #[ doc( alias = "GPU_LUTSCALER_0_25x" ) ]
749+ QuarterX = ctru_sys:: GPU_LUTSCALER_0_25x ,
750+
751+ /// 0.5x scale.
752+ #[ doc( alias = "GPU_LUTSCALER_0_5x" ) ]
753+ HalfX = ctru_sys:: GPU_LUTSCALER_0_5x ,
754+ }
755+
756+ impl TryFrom < u8 > for LutScale {
757+ type Error = String ;
758+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
759+ match value {
760+ ctru_sys:: GPU_LUTSCALER_1x => Ok ( Self :: OneX ) ,
761+ ctru_sys:: GPU_LUTSCALER_2x => Ok ( Self :: TwoX ) ,
762+ ctru_sys:: GPU_LUTSCALER_4x => Ok ( Self :: FourX ) ,
763+ ctru_sys:: GPU_LUTSCALER_8x => Ok ( Self :: EightX ) ,
764+ ctru_sys:: GPU_LUTSCALER_0_25x => Ok ( Self :: QuarterX ) ,
765+ ctru_sys:: GPU_LUTSCALER_0_5x => Ok ( Self :: HalfX ) ,
766+ _ => Err ( "invalid value for LutScale" . to_string ( ) ) ,
767+ }
768+ }
769+ }
770+
771+ /// Bump map modes.
772+ #[ repr( u8 ) ]
773+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
774+ #[ doc( alias = "GPU_BUMPMODE" ) ]
775+ pub enum BumpMappingMode {
776+ /// Disabled.
777+ #[ doc( alias = "GPU_BUMP_NOT_USED" ) ]
778+ NotUsed = ctru_sys:: GPU_BUMP_NOT_USED ,
779+
780+ /// Bump as bump mapping.
781+ #[ doc( alias = "GPU_BUMP_AS_BUMP" ) ]
782+ AsBump = ctru_sys:: GPU_BUMP_AS_BUMP ,
783+
784+ /// Bump as tangent/normal mapping.
785+ #[ doc( alias = "GPU_BUMP_AS_TANG" ) ]
786+ AsTangent = ctru_sys:: GPU_BUMP_AS_TANG ,
787+ }
788+
789+ impl TryFrom < u8 > for BumpMappingMode {
790+ type Error = String ;
791+ fn try_from ( value : u8 ) -> Result < Self , Self :: Error > {
792+ match value {
793+ ctru_sys:: GPU_BUMP_NOT_USED => Ok ( BumpMappingMode :: NotUsed ) ,
794+ ctru_sys:: GPU_BUMP_AS_BUMP => Ok ( BumpMappingMode :: AsBump ) ,
795+ ctru_sys:: GPU_BUMP_AS_TANG => Ok ( BumpMappingMode :: AsTangent ) ,
796+ _ => Err ( "invalid value for BumpMappingMode" . to_string ( ) ) ,
797+ }
798+ }
799+ }
800+
681801#[ cfg( test) ]
682802mod tests {
683803 use super :: Lut ;
0 commit comments