本文整理汇总了Python中rpcore.image.Image类的典型用法代码示例。如果您正苦于以下问题:Python Image类的具体用法?Python Image怎么用?Python Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_maps
def _make_maps(self):
""" Internal method to create the cubemap storage """
# Create the cubemaps for the diffuse and specular components
self._prefilter_map = Image.create_cube(
self._name + "IBLPrefDiff", CubemapFilter.PREFILTER_CUBEMAP_SIZE, "R11G11B10")
self._diffuse_map = Image.create_cube(
self._name + "IBLDiff", CubemapFilter.DIFFUSE_CUBEMAP_SIZE, "R11G11B10")
self._spec_pref_map = Image.create_cube(
self._name + "IBLPrefSpec", self._size, "R11G11B10")
self._specular_map = Image.create_cube(
self._name + "IBLSpec", self._size, "R11G11B10")
# Set the correct filtering modes
for tex in [self._diffuse_map, self._specular_map, self._prefilter_map, self._spec_pref_map]:
tex.set_minfilter(SamplerState.FT_linear)
tex.set_magfilter(SamplerState.FT_linear)
tex.set_clear_color(Vec4(0))
tex.clear_image()
# Use mipmaps for the specular cubemap
self._spec_pref_map.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self._specular_map.set_minfilter(SamplerState.FT_linear_mipmap_linear)
示例2: init_internal_manager
def init_internal_manager(self):
""" Creates the light storage manager and the buffer to store the light data """
self.internal_mgr = InternalLightManager()
self.internal_mgr.set_shadow_update_distance(
self.pipeline.settings["shadows.max_update_distance"])
# Storage for the Lights
per_light_vec4s = 4
self.img_light_data = Image.create_buffer(
"LightData", self.MAX_LIGHTS * per_light_vec4s, "RGBA16")
self.img_light_data.set_clear_color(0)
self.img_light_data.clear_image()
self.pta_max_light_index = PTAInt.empty_array(1)
self.pta_max_light_index[0] = 0
# Storage for the shadow sources
per_source_vec4s = 5
self.img_source_data = Image.create_buffer(
"ShadowSourceData", self.MAX_SOURCES * per_source_vec4s, "RGBA16")
self.img_light_data.set_clear_color(0)
self.img_light_data.clear_image()
# Register the buffer
inputs = self.pipeline.stage_mgr.inputs
inputs["AllLightsData"] = self.img_light_data
inputs["ShadowSourceData"] = self.img_source_data
inputs["maxLightIndex"] = self.pta_max_light_index
示例3: init_internal_manager
def init_internal_manager(self):
""" Creates the light storage manager and the buffer to store the light data """
self.internal_mgr = InternalLightManager()
self.internal_mgr.set_shadow_update_distance(
self.pipeline.settings["shadows.max_update_distance"])
# Storage for the Lights
per_light_vec4s = 4
self.img_light_data = Image.create_buffer(
"LightData", self.MAX_LIGHTS * per_light_vec4s, "RGBA16")
self.img_light_data.clear_image()
self.pta_max_light_index = PTAInt.empty_array(1)
self.pta_max_light_index[0] = 0
# Storage for the shadow sources
per_source_vec4s = 5
# IMPORTANT: RGBA32 is really required here. Otherwise artifacts and bad
# shadow filtering occur due to precision issues
self.img_source_data = Image.create_buffer(
"ShadowSourceData", self.MAX_SOURCES * per_source_vec4s, "RGBA32")
self.img_light_data.clear_image()
# Register the buffer
inputs = self.pipeline.stage_mgr.inputs
inputs["AllLightsData"] = self.img_light_data
inputs["ShadowSourceData"] = self.img_source_data
inputs["maxLightIndex"] = self.pta_max_light_index
示例4: _create_components
def _create_components(self):
""" Internal method to init the widgets components """
# Create the buffer which stores the last FPS values
self._storage_buffer = Image.create_buffer("FPSValues", 250, "R16")
self._storage_buffer.set_clear_color(Vec4(0))
self._storage_buffer.clear_image()
self._store_index = PTAInt.empty_array(1)
self._store_index[0] = 0
self._current_ftime = PTAFloat.empty_array(1)
self._current_ftime[0] = 16.0
self._chart_ms_max = PTAFloat.empty_array(1)
self._chart_ms_max[0] = 40
# Create the texture where the gui component is rendered inside
self._display_tex = Image.create_2d("FPSChartRender", 250, 120, "RGBA8")
self._display_tex.set_clear_color(Vec4(0))
self._display_tex.clear_image()
self._display_img = Sprite(
image=self._display_tex, parent=self._node, w=250, h=120, x=10, y=10)
# Defer the further loading
Globals.base.taskMgr.doMethodLater(0.3, self._late_init, "FPSChartInit")
示例5: create
def create(self):
self.target = self.create_target("CollectUsedCells")
self.target.size = 0, 0
self.target.prepare_buffer()
self.cell_list_buffer = Image.create_buffer("CellList", 0, "R32I")
self.cell_index_buffer = Image.create_2d_array("CellIndices", 0, 0, 0, "R32I")
self.target.set_shader_inputs(
CellListBuffer=self.cell_list_buffer,
CellListIndices=self.cell_index_buffer)
示例6: create
def create(self):
# Create the target which converts the scene color to a luminance
self.target_lum = self.create_target("GetLuminance")
self.target_lum.size = -4
self.target_lum.add_color_attachment(bits=(16, 0, 0, 0))
self.target_lum.prepare_buffer()
self.mip_targets = []
# Create the storage for the exposure, this stores the current and last
# frames exposure
# XXX: We have to use F_r16 instead of F_r32 because of a weird nvidia
# driver bug! However, 16 bits should be enough for sure.
self.tex_exposure = Image.create_buffer("ExposureStorage", 1, "R16")
self.tex_exposure.set_clear_color(Vec4(0.5))
self.tex_exposure.clear_image()
# Create the target which extracts the exposure from the average brightness
self.target_analyze = self.create_target("AnalyzeBrightness")
self.target_analyze.size = 1, 1
self.target_analyze.prepare_buffer()
self.target_analyze.set_shader_input("ExposureStorage", self.tex_exposure)
# Create the target which applies the generated exposure to the scene
self.target_apply = self.create_target("ApplyExposure")
self.target_apply.add_color_attachment(bits=16)
self.target_apply.prepare_buffer()
self.target_apply.set_shader_input("Exposure", self.tex_exposure)
示例7: _create_components
def _create_components(self):
""" Internal method to init the widgets components """
self._node.hide()
# Create the texture where the gui component is rendered inside
self._storage_tex = Image.create_2d("ExposureDisplay", 140, 20, "RGBA8")
self._storage_tex.set_clear_color(Vec4(0.2, 0.6, 1.0, 1.0))
self._storage_tex.clear_image()
self._bg_frame = DirectFrame(
parent=self._node, frameColor=(0.1, 0.1, 0.1, 1.0),
frameSize=(200, 0, -10, -85), pos=(0, 0, 0))
self._display_img = Sprite(
image=self._storage_tex, parent=self._node, w=140, h=20, x=20, y=50)
self._display_txt = Text(
text="Current Exposure".upper(), parent=self._node, x=160, y=40,
size=13, color=Vec3(0.8), align="right")
# Create the shader which generates the visualization texture
self._cshader_node = ComputeNode("ExposureWidget")
self._cshader_node.add_dispatch(140 // 10, 20 // 4, 1)
self._cshader_np = self._node.attach_new_node(self._cshader_node)
# Defer the further loading
Globals.base.taskMgr.doMethodLater(1.0, self._late_init, "ExposureLateInit")
示例8: create
def create(self):
self.target = self.create_target("FlagUsedCells")
self.target.prepare_buffer()
self.cell_grid_flags = Image.create_2d_array(
"CellGridFlags", 0, 0,
self._pipeline.settings["lighting.culling_grid_slices"], "R8")
self.target.set_shader_input("cellGridFlags", self.cell_grid_flags)
示例9: create
def create(self):
if self.remove_fireflies:
self.target_firefly = self.create_target("RemoveFireflies")
self.target_firefly.add_color_attachment(bits=16)
self.target_firefly.prepare_buffer()
self.scene_target_img = Image.create_2d(
"BloomDownsample", Globals.resolution.x, Globals.resolution.y, "R11G11B10")
self.scene_target_img.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self.scene_target_img.set_magfilter(SamplerState.FT_linear)
self.scene_target_img.set_wrap_u(SamplerState.WM_clamp)
self.scene_target_img.set_wrap_v(SamplerState.WM_clamp)
self.scene_target_img.set_clear_color(Vec4(0.1, 0.0, 0.0, 1.0))
self.scene_target_img.clear_image()
self.target_extract = self.create_target("ExtractBrightSpots")
self.target_extract.prepare_buffer()
self.target_extract.set_shader_input("DestTex", self.scene_target_img, False, True, -1, 0)
if self.remove_fireflies:
self.target_extract.set_shader_input("ShadedScene", self.target_firefly.color_tex, 1000)
self.downsample_targets = []
self.upsample_targets = []
# Downsample passes
for i in range(self.num_mips):
scale_multiplier = 2 ** (1 + i)
target = self.create_target("Downsample:Step-" + str(i))
target.size = -scale_multiplier, -scale_multiplier
target.prepare_buffer()
target.set_shader_input("sourceMip", i)
target.set_shader_input("SourceTex", self.scene_target_img)
target.set_shader_input("DestTex", self.scene_target_img, False, True, -1, i + 1)
self.downsample_targets.append(target)
# Upsample passes
for i in range(self.num_mips):
scale_multiplier = 2 ** (self.num_mips - i - 1)
target = self.create_target("Upsample:Step-" + str(i))
target.size = -scale_multiplier, -scale_multiplier
target.prepare_buffer()
target.set_shader_input("FirstUpsamplePass", i == 0)
target.set_shader_input("sourceMip", self.num_mips - i)
target.set_shader_input("SourceTex", self.scene_target_img)
target.set_shader_input("DestTex", self.scene_target_img,
False, True, -1, self.num_mips - i - 1)
self.upsample_targets.append(target)
self.target_apply = self.create_target("ApplyBloom")
self.target_apply.add_color_attachment(bits=16)
self.target_apply.prepare_buffer()
self.target_apply.set_shader_input("BloomTex", self.scene_target_img)
示例10: create
def create(self):
# TODO: Use no oversized triangle in this stage
self.target = self.create_target("CullProbes")
self.target.size = 0, 0
self.target.prepare_buffer()
self.per_cell_probes = Image.create_buffer("PerCellProbes", 0, "R32I")
self.per_cell_probes.clear_image()
self.target.set_shader_input("PerCellProbes", self.per_cell_probes)
self.target.set_shader_input("threadCount", 1)
示例11: create
def create(self):
tile_amount = self._pipeline.light_mgr.num_tiles
self.target = self.create_target("CollectUsedCells")
self.target.size = tile_amount.x, tile_amount.y
self.target.prepare_buffer()
num_slices = self._pipeline.settings["lighting.culling_grid_slices"]
max_cells = tile_amount.x * tile_amount.y * num_slices
self.debug("Allocating", max_cells, "cells")
self._cell_list_buffer = Image.create_buffer("CellList", 1 + max_cells, "R32I")
self._cell_list_buffer.set_clear_color(0)
self._cell_index_buffer = Image.create_2d_array(
"CellIndices", tile_amount.x, tile_amount.y, num_slices, "R32I")
self._cell_index_buffer.set_clear_color(0)
self.target.set_shader_input("CellListBuffer", self._cell_list_buffer)
self.target.set_shader_input("CellListIndices", self._cell_index_buffer)
示例12: _create_storage
def _create_storage(self):
""" Internal method to create the storage for the profile dataset textures """
self._storage_tex = Image.create_3d("IESDatasets", 512, 512, self._max_entries, "R16")
self._storage_tex.set_minfilter(SamplerState.FT_linear)
self._storage_tex.set_magfilter(SamplerState.FT_linear)
self._storage_tex.set_wrap_u(SamplerState.WM_clamp)
self._storage_tex.set_wrap_v(SamplerState.WM_repeat)
self._storage_tex.set_wrap_w(SamplerState.WM_clamp)
self._pipeline.stage_mgr.inputs["IESDatasetTex"] = self._storage_tex
self._pipeline.stage_mgr.defines["MAX_IES_PROFILES"] = self._max_entries
示例13: create
def create(self):
self.target = self.create_target("FlagUsedCells")
self.target.prepare_buffer()
tile_amount = self._pipeline.light_mgr.num_tiles
self.cell_grid_flags = Image.create_2d_array(
"CellGridFlags", tile_amount.x, tile_amount.y,
self._pipeline.settings["lighting.culling_grid_slices"], "R8")
self.cell_grid_flags.set_clear_color(0)
self.target.set_shader_input("cellGridFlags", self.cell_grid_flags)
示例14: init
def init(self):
""" Creates the cubemap storage """
# Storage for the specular components (with mipmaps)
self.cubemap_storage = Image.create_cube_array(
"EnvmapStorage", self.resolution, self.max_probes, "RGBA16")
self.cubemap_storage.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self.cubemap_storage.set_magfilter(SamplerState.FT_linear)
self.cubemap_storage.set_clear_color(Vec4(1.0, 0.0, 0.1, 1.0))
self.cubemap_storage.clear_image()
# Storage for the diffuse component
self.diffuse_storage = Image.create_cube_array(
"EnvmapDiffStorage", self.diffuse_resolution, self.max_probes, "RGBA16")
self.diffuse_storage.set_clear_color(Vec4(1, 0, 0.2, 1.0))
self.diffuse_storage.clear_image()
# Data-storage to store all cubemap properties
self.dataset_storage = Image.create_buffer(
"EnvmapData", self.max_probes * 5, "RGBA32")
self.dataset_storage.set_clear_color(Vec4(0))
self.dataset_storage.clear_image()
示例15: create
def create(self):
# Create the target which converts the scene color to a luminance
self.target_lum = self.create_target("GetLuminance")
self.target_lum.size = -4
self.target_lum.add_color_attachment(bits=(16, 0, 0, 0))
self.target_lum.prepare_buffer()
# Get the current quarter-window size
wsize_x = (Globals.resolution.x + 3) // 4
wsize_y = (Globals.resolution.y + 3) // 4
# Create the targets which downscale the luminance mipmaps
self.mip_targets = []
last_tex = self.target_lum.color_tex
while wsize_x >= 4 or wsize_y >= 4:
wsize_x = (wsize_x+3) // 4
wsize_y = (wsize_y+3) // 4
mip_target = self.create_target("DScaleLum:S" + str(wsize_x))
mip_target.add_color_attachment(bits=(16, 0, 0, 0))
mip_target.size = wsize_x, wsize_y
mip_target.prepare_buffer()
mip_target.set_shader_input("SourceTex", last_tex)
self.mip_targets.append(mip_target)
last_tex = mip_target.color_tex
# Create the storage for the exposure, this stores the current and last
# frames exposure
# XXX: We have to use F_r16 instead of F_r32 because of a weird nvidia
# driver bug! However, 16 bits should be enough for sure.
self.tex_exposure = Image.create_buffer("ExposureStorage", 1, "R16")
self.tex_exposure.set_clear_color(Vec4(0.5))
self.tex_exposure.clear_image()
# Create the target which extracts the exposure from the average brightness
self.target_analyze = self.create_target("AnalyzeBrightness")
self.target_analyze.size = 1, 1
self.target_analyze.prepare_buffer()
self.target_analyze.set_shader_input(
"ExposureStorage", self.tex_exposure)
self.target_analyze.set_shader_input("DownscaledTex", last_tex)
# Create the target which applies the generated exposure to the scene
self.target_apply = self.create_target("ApplyExposure")
self.target_apply.add_color_attachment(bits=16)
self.target_apply.prepare_buffer()
self.target_apply.set_shader_input("Exposure", self.tex_exposure)