diff --git a/nmsr-3d-renderer/nmsr-player-parts/src/types.rs b/nmsr-3d-renderer/nmsr-player-parts/src/types.rs index 837b6fd..4f89c4d 100644 --- a/nmsr-3d-renderer/nmsr-player-parts/src/types.rs +++ b/nmsr-3d-renderer/nmsr-player-parts/src/types.rs @@ -74,7 +74,7 @@ pub enum PlayerPartTextureType { Shadow, Cape, Skin, - Custom { key: &'static str, size: (u32, u32) }, + Custom { key: &'static str, size: (u32, u32), is_emissive: bool }, } impl std::fmt::Display for PlayerPartTextureType { @@ -89,6 +89,13 @@ impl std::fmt::Display for PlayerPartTextureType { } impl PlayerPartTextureType { + pub fn is_emissive(&self) -> bool { + match self { + Self::Custom { is_emissive, .. } => *is_emissive, + _ => false, + } + } + pub fn get_texture_size(&self) -> (u32, u32) { match self { Self::Skin => (64, 64), diff --git a/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene.rs b/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene.rs index 6fcdbe7..897d34f 100644 --- a/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene.rs +++ b/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene.rs @@ -224,6 +224,7 @@ where let transform_bind_group = &self.scene_context.transform_bind_group; let sun_bind_group = &self.scene_context.sun_information_bind_group; + let emissive_sun_bind_group = &self.scene_context.emissive_sun_information_bind_group; let textures = self .scene_context @@ -369,7 +370,13 @@ where rpass.set_pipeline(pipeline); rpass.set_bind_group(0, transform_bind_group, &[]); rpass.set_bind_group(1, &texture_sampler_bind_group, &[]); - rpass.set_bind_group(2, sun_bind_group, &[]); + + if !texture.is_emissive() { + rpass.set_bind_group(2, sun_bind_group, &[]); + } else { + rpass.set_bind_group(2, emissive_sun_bind_group, &[]); + } + rpass.set_index_buffer(index_buf.slice(..), IndexFormat::Uint16); rpass.set_vertex_buffer(0, vertex_buf.slice(..)); rpass.draw_indexed(0..(index_data.len() as u32), 0, 0..1); diff --git a/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene_context.rs b/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene_context.rs index 31b9d1f..7d440fe 100644 --- a/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene_context.rs +++ b/nmsr-3d-renderer/nmsr-rendering/src/high_level/pipeline/scene_context.rs @@ -29,6 +29,8 @@ pub struct SceneContext { pub transform_bind_group: BindGroup, pub sun_information_buffer: Buffer, pub sun_information_bind_group: BindGroup, + pub emissive_sun_information_buffer: Buffer, + pub emissive_sun_information_bind_group: BindGroup, pub(crate) textures: Option, #[debug(skip)] pub(crate) smaa_target: Option, @@ -55,11 +57,21 @@ impl SceneContext { &[SunInformation::default()], ); + let (emissive_sun_information_buffer, emissive_sun_information_bind_group) = + create_buffer_and_bind_group( + device, + "Emissive Sun", + &context.layouts.sun_bind_group_layout, + &[SunInformation::new([0.0; 3].into(), 0.0, 1.0f32)], + ); + Self { transform_bind_group, transform_matrix_buffer, sun_information_buffer, sun_information_bind_group, + emissive_sun_information_buffer, + emissive_sun_information_bind_group, textures: None, smaa_target: None, } diff --git a/nmsr-aas/src/model/armor/mod.rs b/nmsr-aas/src/model/armor/mod.rs index 63f38eb..d04512d 100644 --- a/nmsr-aas/src/model/armor/mod.rs +++ b/nmsr-aas/src/model/armor/mod.rs @@ -158,11 +158,13 @@ impl VanillaMinecraftArmorMaterialData { pub const ARMOR_TEXTURE_ONE: PlayerPartTextureType = PlayerPartTextureType::Custom { key: "armor_1", size: (64, 64), + is_emissive: false }; pub const ARMOR_TEXTURE_TWO: PlayerPartTextureType = PlayerPartTextureType::Custom { key: "armor_2", size: (64, 64), + is_emissive: false }; #[must_use] diff --git a/nmsr-aas/src/model/request/cache.rs b/nmsr-aas/src/model/request/cache.rs index 5978763..a7bc6ca 100644 --- a/nmsr-aas/src/model/request/cache.rs +++ b/nmsr-aas/src/model/request/cache.rs @@ -357,6 +357,8 @@ impl CacheHandler for PlayerPartEarsTextureType { ResolvedRenderEntryEarsTextureType::EmissiveProcessedSkin => { Self::EmissiveProcessedSkin } + ResolvedRenderEntryEarsTextureType::EmissiveProcessedWings => { + Self::EmissiveProcessedWings + } ResolvedRenderEntryEarsTextureType::EmissiveWings => Self::EmissiveWings, } } @@ -88,7 +93,10 @@ impl ResolvedRenderEntryEarsTextureType { match self { Self::Cape => Some(AlfalfaDataKey::Cape), Self::Wings => Some(AlfalfaDataKey::Wings), - Self::EmissiveSkin | Self::EmissiveProcessedSkin | Self::EmissiveWings => None, + Self::EmissiveSkin + | Self::EmissiveProcessedSkin + | Self::EmissiveProcessedWings + | Self::EmissiveWings => None, } } @@ -440,7 +448,7 @@ impl RenderRequestResolver { ), ( ResolvedRenderEntryTextureType::Ears(ResolvedRenderEntryEarsTextureType::Wings), - None, + Some(ResolvedRenderEntryTextureType::Ears(ResolvedRenderEntryEarsTextureType::EmissiveProcessedWings)), ResolvedRenderEntryTextureType::Ears( ResolvedRenderEntryEarsTextureType::EmissiveWings, ),