def _create_textureset(self): texset = NifFormat.BSShaderTextureSet() if self.slots["Base"]: texset.textures[0] = TextureWriter.export_texture_filename(self.slots["Base"]) if self.slots["Normal"]: texset.textures[1] = TextureWriter.export_texture_filename(self.slots["Normal"]) if self.slots["Glow"]: texset.textures[2] = TextureWriter.export_texture_filename(self.slots["Glow"]) if self.slots["Detail"]: texset.textures[3] = TextureWriter.export_texture_filename(self.slots["Detail"]) return texset
def _create_textureset(self): texset = NifFormat.BSShaderTextureSet() if self.slots[TEX_SLOTS.BASE]: texset.textures[0] = TextureWriter.export_texture_filename( self.slots[TEX_SLOTS.BASE]) if self.slots[TEX_SLOTS.NORMAL]: texset.textures[1] = TextureWriter.export_texture_filename( self.slots[TEX_SLOTS.NORMAL]) if self.slots[TEX_SLOTS.GLOW]: texset.textures[2] = TextureWriter.export_texture_filename( self.slots[TEX_SLOTS.GLOW]) if self.slots[TEX_SLOTS.DETAIL]: texset.textures[3] = TextureWriter.export_texture_filename( self.slots[TEX_SLOTS.DETAIL]) return texset
def export_bs_shader_property(self, b_obj=None, b_mat=None): """Export a Bethesda shader property block.""" self.determine_texture_types(b_obj, b_mat) # create new block if b_obj.niftools_shader.bs_shadertype == 'BSShaderPPLightingProperty': bsshader = NifFormat.BSShaderPPLightingProperty() # set shader options # TODO: FIXME: b_s_type = NifFormat.BSShaderType._enumkeys.index( b_obj.niftools_shader.bsspplp_shaderobjtype) bsshader.shader_type = NifFormat.BSShaderType._enumvalues[b_s_type] # Shader Flags if hasattr(bsshader, 'shader_flags'): self.export_shader_flags(b_obj, bsshader) if b_obj.niftools_shader.bs_shadertype == 'BSLightingShaderProperty': bsshader = NifFormat.BSLightingShaderProperty() b_s_type = NifFormat.BSLightingShaderPropertyShaderType._enumkeys.index( b_obj.niftools_shader.bslsp_shaderobjtype) bsshader.shader_type = NifFormat.BSLightingShaderPropertyShaderType._enumvalues[ b_s_type] # UV Offset if hasattr(bsshader, 'uv_offset'): self.export_uv_offset(bsshader) # UV Scale if hasattr(bsshader, 'uv_scale'): self.export_uv_scale(bsshader) # Texture Clamping mode if not self.base_mtex.texture.image.use_clamp_x: wrap_s = 2 else: wrap_s = 0 if not self.base_mtex.texture.image.use_clamp_y: wrap_t = 1 else: wrap_t = 0 bsshader.texture_clamp_mode = (wrap_s + wrap_t) # Diffuse color bsshader.skin_tint_color.r = b_mat.diffuse_color.r bsshader.skin_tint_color.g = b_mat.diffuse_color.g bsshader.skin_tint_color.b = b_mat.diffuse_color.b # b_mat.diffuse_intensity = 1.0 bsshader.lighting_effect_1 = b_mat.niftools.lightingeffect1 bsshader.lighting_effect_2 = b_mat.niftools.lightingeffect2 # Emissive bsshader.emissive_color.r = b_mat.niftools.emissive_color.r bsshader.emissive_color.g = b_mat.niftools.emissive_color.g bsshader.emissive_color.b = b_mat.niftools.emissive_color.b bsshader.emissive_multiple = b_mat.emit # gloss bsshader.glossiness = b_mat.specular_hardness # Specular color bsshader.specular_color.r = b_mat.specular_color.r bsshader.specular_color.g = b_mat.specular_color.g bsshader.specular_color.b = b_mat.specular_color.b bsshader.specular_strength = b_mat.specular_intensity # Alpha if b_mat.use_transparency: bsshader.alpha = (1 - b_mat.alpha) # Shader Flags if hasattr(bsshader, 'shader_flags_1'): self.export_shader_flags(b_obj, bsshader) if b_obj.niftools_shader.bs_shadertype == 'BSEffectShaderProperty': bsshader = NifFormat.BSEffectShaderProperty() # Alpha if b_mat.use_transparency: bsshader.alpha = (1 - b_mat.alpha) # clamp Mode bsshader.texture_clamp_mode = 65283 # Emissive bsshader.emissive_color.r = b_mat.niftools.emissive_color.r bsshader.emissive_color.g = b_mat.niftools.emissive_color.g bsshader.emissive_color.b = b_mat.niftools.emissive_color.b bsshader.emissive_color.a = b_mat.niftools.emissive_alpha bsshader.emissive_multiple = b_mat.emit # Shader Flags if hasattr(bsshader, 'shader_flags_1'): self.export_shader_flags(b_obj, bsshader) if b_obj.niftools_shader.bs_shadertype == 'None': raise nif_utils.NifError( "Export version expected shader. " "No shader applied to mesh '%s', these cannot be exported to NIF." " Set shader before exporting." % b_obj) # set textures texset = NifFormat.BSShaderTextureSet() bsshader.texture_set = texset if self.base_mtex: texset.textures[0] = self.texture_writer.export_texture_filename( self.base_mtex.texture) if self.normal_mtex: texset.textures[1] = self.texture_writer.export_texture_filename( self.normal_mtex.texture) if self.glow_mtex: texset.textures[2] = self.texture_writer.export_texture_filename( self.glow_mtex.texture) if self.detail_mtex: texset.textures[3] = self.texture_writer.export_texture_filename( self.detail_mtex.texture) if b_obj.niftools_shader.bs_shadertype == 'BSLightingShaderProperty': texset.num_textures = 9 texset.textures.update_size() if self.detail_mtex: texset.textures[ 6] = self.texture_writer.export_texture_filename( self.detail_mtex.texture) if self.gloss_mtex: texset.textures[ 7] = self.texture_writer.export_texture_filename( self.gloss_mtex.texture) if b_obj.niftools_shader.bs_shadertype == 'BSEffectShaderProperty': bsshader.source_texture = self.texture_writer.export_texture_filename( self.base_mtex.texture) bsshader.greyscale_texture = self.texture_writer.export_texture_filename( self.glow_mtex.texture) return bsshader