def __init__(self, **texture_data): self.name = texture_data.get('name') self.attachment = False self.image_mode = "RGBA" self.internal_format = GL_RGBA8 self.texture_format = GL_RGBA self.sRGB = False self.clear_color = None self.multisample_count = 0 self.width = 0 self.height = 0 self.depth = 1 self.data_type = GL_UNSIGNED_BYTE self.min_filter = GL_LINEAR_MIPMAP_LINEAR self.mag_filter = GL_LINEAR self.enable_mipmap = False self.wrap = self.default_wrap self.wrap_s = self.default_wrap self.wrap_t = self.default_wrap self.wrap_r = self.default_wrap self.buffer = -1 self.sampler_handle = -1 self.attribute = Attributes() self.create_texture(**texture_data)
def __init__(self, **data): self.name = self.__class__.__name__ self.texture_name = 'vector_field_3d' self.texture_width = data.get('texture_width', 256) self.texture_height = data.get('texture_height', 256) self.texture_depth = data.get('texture_depth', 256) self.attribute = Attributes()
def __init__(self, material_instance_name, **data): self.valid = False self.isNeedToSave = False logger.info("Load Material Instance : " + material_instance_name) self.name = material_instance_name self.shader_name = data.get('shader_name', 'default') self.material = None self.material_name = data.get('material_name', 'default') self.macros = copy.copy(data.get('macros', OrderedDict())) self.linked_uniform_map = dict() self.linked_material_component_map = dict() self.show_message = {} self.Attributes = Attributes() material = data.get('material') # link uniform_buffers and uniform_data self.set_material(material) if self.material: # and set the loaded uniform data. uniform_datas = data.get('uniform_datas', {}) for data_name, data_value in uniform_datas.items(): self.set_uniform_data_from_string(data_name, data_value) else: logger.error("%s material instance has no material." % self.name) return self.valid = True
def __init__(self, **data): self.name = self.__class__.__name__ self.texture_name = 'noise_3d' self.noise_width = data.get('noise_width', 256) self.noise_height = data.get('noise_height', 256) self.noise_depth = data.get('noise_depth', 32) self.noise_persistance = data.get('noise_persistance', 0.7) self.noise_scale = data.get('noise_scale', 6) self.attribute = Attributes()
def __init__(self, **object_data): self.name = object_data.get('name', 'atmosphere') self.attributes = Attributes() self.is_render_atmosphere = object_data.get('is_render_atmosphere', True) self.use_constant_solar_spectrum = False self.use_ozone = True self.use_combined_textures = True self.luminance_type = Luminance.NONE self.num_precomputed_wavelengths = 15 if Luminance.PRECOMPUTED == self.luminance_type else 3 self.do_white_balance = False self.show_help = True self.view_distance_meters = 9000.0 self.view_zenith_angle_radians = 1.47 self.view_azimuth_angle_radians = -0.1 self.sun_zenith_angle_radians = 1.3 self.sun_azimuth_angle_radians = 2.9 self.sun_direction = Float3() self.white_point = Float3() self.earth_center = Float3(0.0, -kBottomRadius / kLengthUnitInMeters, 0.0) self.sun_size = Float2(math.tan(kSunAngularRadius), math.cos(kSunAngularRadius)) self.kSky = Float3(1.0, 1.0, 1.0) self.kSun = Float3(1.0, 1.0, 1.0) self.atmosphere_exposure = 0.0001 # cloud constants self.cloud_altitude = 100.0 self.cloud_height = 500.0 self.cloud_speed = 0.01 self.cloud_absorption = 0.15 self.cloud_contrast = 2.0 self.cloud_coverage = 0.8 self.cloud_tiling = 0.0004 self.noise_contrast = 1.0 self.noise_coverage = 1.0 self.noise_tiling = 0.0003 self.model = None self.atmosphere_material_instance = None self.transmittance_texture = None self.scattering_texture = None self.irradiance_texture = None self.optional_single_mie_scattering_texture = None self.cloud_texture = None self.noise_texture = None self.quad = ScreenQuad.get_vertex_array_buffer() self.load_data(object_data) self.initialize()
def __init__(self, name, **data): self.name = name self.mesh = None self.material_instances = [] self.set_mesh(data.get('mesh')) for i, material_instance in enumerate(data.get('material_instances', [])): self.set_material_instance(material_instance, i) self.attributes = Attributes()
def __init__(self, **data): self.name = self.__class__.__name__ self.texture_name = 'cloud_3d' self.width = data.get('width', 128) self.height = data.get('height', 128) self.depth = data.get('depth', 128) self.sphere_scale = data.get('sphere_scale', 0.15) self.sphere_count = data.get('sphere_count', 4096) self.noise_persistance = data.get('noise_persistance', 0.7) self.noise_scale = data.get('noise_scale', 6) self.attribute = Attributes()
def __init__(self, material_name, material_datas={}): self.valid = False logger.info("Load %s material." % material_name) # for save self.material_datas = material_datas shader_codes = material_datas.get('shader_codes') binary_format = material_datas.get('binary_format') binary_data = material_datas.get('binary_data') uniforms = material_datas.get('uniforms', []) uniform_datas = material_datas.get('uniform_datas', {}) self.material_component_names = [ x[1] for x in material_datas.get('material_components', []) ] self.macros = material_datas.get('macros', OrderedDict()) self.is_translucent = True if 0 < self.macros.get( 'TRANSPARENT_MATERIAL', 0) else False self.name = material_name self.shader_name = material_datas.get('shader_name', '') self.program = -1 self.uniform_buffers = dict( ) # OrderedDict() # Declaration order is important. self.Attributes = Attributes() if CoreManager.instance().is_basic_mode: self.valid = True else: if binary_format is not None and binary_data is not None: self.compile_from_binary(binary_format, binary_data) self.valid = self.check_validate() and self.check_linked() if not self.valid: logger.error( "%s material has been failed to compile from binary" % self.name) self.compile_message = "" if not self.valid: self.compile_from_source(shader_codes) self.valid = self.check_validate() and self.check_linked() if not self.valid: logger.error( "%s material has been failed to compile from source" % self.name) if self.valid: self.create_uniform_buffers(uniforms, uniform_datas)
def create_texture(self, **texture_data): if self.buffer != -1: self.delete() self.attachment = False self.image_mode = texture_data.get('image_mode') self.internal_format = texture_data.get('internal_format') self.texture_format = texture_data.get('texture_format') self.sRGB = texture_data.get('sRGB', False) self.clear_color = texture_data.get('clear_color') self.multisample_count = 0 if self.internal_format is None and self.image_mode: self.internal_format = get_internal_format(self.image_mode) if self.texture_format is None and self.image_mode: self.texture_format = get_texture_format(self.image_mode) if self.image_mode is None and self.texture_format: self.image_mode = get_image_mode(self.texture_format) # Convert to sRGB if self.sRGB: if self.internal_format == GL_RGB: self.internal_format = GL_SRGB8 elif self.internal_format == GL_RGBA: self.internal_format = GL_SRGB8_ALPHA8 if GL_RGBA == self.internal_format: self.internal_format = GL_RGBA8 if GL_RGB == self.internal_format: self.internal_format = GL_RGB8 self.width = int(texture_data.get('width', 0)) self.height = int(texture_data.get('height', 0)) self.depth = int(max(1, texture_data.get('depth', 1))) self.data_type = texture_data.get('data_type', GL_UNSIGNED_BYTE) self.min_filter = texture_data.get('min_filter', GL_LINEAR_MIPMAP_LINEAR) self.mag_filter = texture_data.get('mag_filter', GL_LINEAR) # GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_NEAREST mipmap_filters = (GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST) self.enable_mipmap = self.min_filter in mipmap_filters if self.target == GL_TEXTURE_2D_MULTISAMPLE: self.enable_mipmap = False self.wrap = texture_data.get('wrap', self.default_wrap) # GL_REPEAT, GL_CLAMP self.wrap_s = texture_data.get('wrap_s') self.wrap_t = texture_data.get('wrap_t') self.wrap_r = texture_data.get('wrap_r') self.buffer = -1 self.sampler_handle = -1 # texture parameter overwrite # self.sampler_handle = glGenSamplers(1) # glSamplerParameteri(self.sampler_handle, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) # glBindSampler(0, self.sampler_handle) logger.info("Create %s : %s %dx%dx%d %s mipmap(%s)." % ( GetClassName(self), self.name, self.width, self.height, self.depth, str(self.internal_format), 'Enable' if self.enable_mipmap else 'Disable')) self.attribute = Attributes()
def __init__(self, shader_name, shader_code): logger.info("Load " + GetClassName(self) + " : " + shader_name) self.name = shader_name self.shader_code = shader_code self.include_files = [] self.attribute = Attributes()