本文整理匯總了Python中rpcore.loader.RPLoader類的典型用法代碼示例。如果您正苦於以下問題:Python RPLoader類的具體用法?Python RPLoader怎麽用?Python RPLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RPLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _late_init
def _late_init(self, task):
""" Gets called after the pipeline was initialized """
self._display_txt = Text(
text="40 ms", parent=self._node, x=20, y=25,
size=13, color=Vec3(1), may_change=True)
self._display_txt_bottom = Text(
text="0 ms", parent=self._node, x=20, y=120,
size=13, color=Vec3(1), may_change=True)
# Create the shader which generates the visualization texture
self._cshader_node = ComputeNode("FPSChartUpdateChart")
self._cshader_node.add_dispatch(250 // 10, 120 // 4, 1)
self._cshader_np = self._node.attach_new_node(self._cshader_node)
self._cshader = RPLoader.load_shader("/$$rp/shader/fps_chart.compute.glsl")
self._cshader_np.set_shader(self._cshader)
self._cshader_np.set_shader_input("DestTex", self._display_tex)
self._cshader_np.set_shader_input("FPSValues", self._storage_buffer)
self._cshader_np.set_shader_input("index", self._store_index)
self._cshader_np.set_shader_input("maxMs", self._chart_ms_max)
self._update_shader_node = ComputeNode("FPSChartUpdateValues")
self._update_shader_node.add_dispatch(1, 1, 1)
self._update_shader_np = self._node.attach_new_node(self._update_shader_node)
self._ushader = RPLoader.load_shader("/$$rp/shader/fps_chart_update.compute.glsl")
self._update_shader_np.set_shader(self._ushader)
self._update_shader_np.set_shader_input("DestTex", self._storage_buffer)
self._update_shader_np.set_shader_input("index", self._store_index)
self._update_shader_np.set_shader_input("currentData", self._current_ftime)
Globals.base.addTask(self._update, "UpdateFPSChart", sort=-50)
return task.done
示例2: on_pipeline_created
def on_pipeline_created(self):
cloud_voxels = RPLoader.load_3d_texture(self.get_resource("slices/#.png"))
cloud_voxels.set_wrap_w(SamplerState.WM_clamp)
self.apply_stage.set_shader_input("CloudVoxels", cloud_voxels)
noise_tex = RPLoader.load_texture(self.get_resource("noise.png"))
noise_tex.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self.apply_stage.set_shader_input("NoiseTex", noise_tex)
示例3: _load_textures
def _load_textures(self):
""" Loads all required textures """
search_tex = RPLoader.load_texture(self.get_resource("search_tex.png"))
area_tex = RPLoader.load_texture(self.get_resource("area_tex.png"))
for tex in [search_tex, area_tex]:
tex.set_minfilter(SamplerState.FT_linear)
tex.set_magfilter(SamplerState.FT_linear)
tex.set_wrap_u(SamplerState.WM_clamp)
tex.set_wrap_v(SamplerState.WM_clamp)
self._smaa_stage.area_tex = area_tex
self._smaa_stage.search_tex = search_tex
示例4: _load_fonts
def _load_fonts(self):
""" Loads the default font used for rendering and assigns it to
Globals.font for further usage """
Globals.font = RPLoader.load_font("/$$rp/data/font/roboto-medium.ttf")
Globals.font.set_pixels_per_unit(35)
Globals.font.set_poly_margin(0.0)
Globals.font.set_texture_margin(1)
示例5: _late_init
def _late_init(self, task):
""" Gets called after the pipeline got initialized """
scene_tex = self._pipeline.stage_mgr.pipes["ShadedScene"]
self._zoomer.set_shader(RPLoader.load_shader(
"/$$rp/shader/default_gui_shader.vert.glsl",
"/$$rp/shader/pixel_inspector.frag.glsl"))
self._zoomer.set_shader_input("SceneTex", scene_tex)
return task.done
示例6: _load_grain
def _load_grain(self):
grain_tex = RPLoader.load_texture(
"/$$rp/data/film_grain/grain.txo")
grain_tex.set_minfilter(SamplerState.FT_linear)
grain_tex.set_magfilter(SamplerState.FT_linear)
grain_tex.set_wrap_u(SamplerState.WM_repeat)
grain_tex.set_wrap_v(SamplerState.WM_repeat)
grain_tex.set_anisotropic_degree(0)
self._stage.set_shader_input("PrecomputedGrain", grain_tex)
示例7: create_shaders
def create_shaders(self):
""" Creates all the shaders used for precomputing """
self.shaders = {}
resource_path = self.handle.get_shader_resource("eric_bruneton")
for fname in listdir(resource_path):
fpath = join(resource_path, fname)
if isfile(fpath) and fname.endswith(".compute.glsl"):
shader_name = fname.split(".")[0]
shader_obj = RPLoader.load_shader(fpath)
self.shaders[shader_name] = shader_obj
示例8: _load_fonts
def _load_fonts(self):
""" Loads the default font used for rendering and assigns it to
Globals.font for further usage """
font = RPLoader.load_font("/$$rp/data/font/Roboto-Medium.ttf")
font.set_pixels_per_unit(35)
font.set_poly_margin(0.0)
font.set_texture_margin(1)
font.set_bg(Vec4(1, 1, 1, 0))
font.set_fg(Vec4(1, 1, 1, 1))
Globals.font = font
示例9: _load_lut
def _load_lut(self):
""" Loads the color correction lookup table (LUT) """
lut_path = self.get_resource(self.get_setting("color_lut"))
lut = RPLoader.load_sliced_3d_texture(lut_path, 64)
lut.set_wrap_u(SamplerState.WM_clamp)
lut.set_wrap_v(SamplerState.WM_clamp)
lut.set_wrap_w(SamplerState.WM_clamp)
lut.set_minfilter(SamplerState.FT_linear)
lut.set_magfilter(SamplerState.FT_linear)
lut.set_anisotropic_degree(0)
self._tonemapping_stage.set_shader_input("ColorLUT", lut)
示例10: _load_environment_cubemap
def _load_environment_cubemap(self):
""" Loads the default cubemap used for the environment, which is used
when no other environment data is available """
envmap = RPLoader.load_cube_map(
"/$$rp/data/default_cubemap/cubemap.txo", read_mipmaps=True)
envmap.set_minfilter(SamplerState.FT_linear_mipmap_linear)
# envmap.set_format(Image.F_rgba16)
envmap.set_magfilter(SamplerState.FT_linear)
envmap.set_wrap_u(SamplerState.WM_repeat)
envmap.set_wrap_v(SamplerState.WM_repeat)
envmap.set_wrap_w(SamplerState.WM_repeat)
self._pipeline.stage_mgr.inputs["DefaultEnvmap"] = envmap
示例11: __init__
def __init__(self, parent=None, x=0, y=0, callback=None, extra_args=None,
radio=False, expand_width=100, checked=False, enabled=True):
RPObject.__init__(self)
prefix = "checkbox" if not radio else "radiobox"
if enabled:
checked_img = RPLoader.load_texture(
"/$$rp/data/gui/" + prefix + "_checked.png")
unchecked_img = RPLoader.load_texture(
"/$$rp/data/gui/" + prefix + "_default.png")
else:
checked_img = RPLoader.load_texture(
"/$$rp/data/gui/" + prefix + "_disabled.png")
unchecked_img = checked_img
# Set near filter, otherwise textures look like crap
for tex in [checked_img, unchecked_img]:
tex.set_minfilter(SamplerState.FT_linear)
tex.set_magfilter(SamplerState.FT_linear)
tex.set_wrap_u(SamplerState.WM_clamp)
tex.set_wrap_v(SamplerState.WM_clamp)
tex.set_anisotropic_degree(0)
self._node = DirectCheckBox(
parent=parent, pos=(x + 11, 1, -y - 8), scale=(10 / 2.0, 1, 10 / 2.0),
checkedImage=checked_img, uncheckedImage=unchecked_img,
image=unchecked_img, extraArgs=extra_args, state=DGG.NORMAL,
relief=DGG.FLAT, command=self._update_status)
self._node["frameColor"] = (0, 0, 0, 0)
self._node["frameSize"] = (-2.6, 2 + expand_width / 7.5, -2.35, 2.5)
self._node.set_transparency(TransparencyAttrib.M_alpha)
self._callback = callback
self._extra_args = extra_args
self._collection = None
if checked:
self.set_checked(True, False)
示例12: on_pipeline_created
def on_pipeline_created(self):
# High-res noise
noise1 = RPLoader.load_texture(self.get_resource("noise1-data.txo"))
noise1.set_wrap_u(SamplerState.WM_repeat)
noise1.set_wrap_v(SamplerState.WM_repeat)
noise1.set_wrap_w(SamplerState.WM_repeat)
noise1.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self.apply_stage.set_shader_input("Noise1", noise1)
# Low-res noise
noise2 = RPLoader.load_texture(self.get_resource("noise2-data.txo"))
noise2.set_wrap_u(SamplerState.WM_repeat)
noise2.set_wrap_v(SamplerState.WM_repeat)
noise2.set_wrap_w(SamplerState.WM_repeat)
noise2.set_minfilter(SamplerState.FT_linear_mipmap_linear)
self.apply_stage.set_shader_input("Noise2", noise2)
# Weather tex
weather = RPLoader.load_texture(self.get_resource("weather_tex.png"))
weather.set_wrap_u(SamplerState.WM_repeat)
weather.set_wrap_v(SamplerState.WM_repeat)
self.apply_stage.set_shader_input("WeatherTex", weather)
示例13: __init__
def __init__(self, image=None, parent=None, x=0, y=0, w=None, h=None,
transparent=True, near_filter=True, any_filter=True):
""" Creates a new image, taking (x,y) as topleft coordinates.
When near_filter is set to true, a near filter will be set to the
texture passed. This provides sharper images.
When any_filter is set to false, the passed image won't be modified at
all. This enables you to display existing textures, otherwise the
texture would get a near filter in the 3D View, too. """
RPObject.__init__(self)
if not isinstance(image, Texture):
if not isinstance(image, str):
self.warn("Invalid argument to image parameter:", image)
return
image = RPLoader.load_texture(image)
if w is None or h is None:
w, h = image.get_x_size(), image.get_y_size()
else:
if w is None or h is None:
w = 10
h = 10
self._width, self._height = w, h
self._initial_pos = self._translate_pos(x, y)
self.node = OnscreenImage(
image=image, parent=parent, pos=self._initial_pos,
scale=(self._width / 2.0, 1, self._height / 2.0))
if transparent:
self.node.set_transparency(TransparencyAttrib.M_alpha)
tex = self.node.get_texture()
# Apply a near filter, but only if the parent has no scale, otherwise
# it will look weird
if near_filter and any_filter and parent.get_sx() == 1.0:
tex.set_minfilter(SamplerState.FT_nearest)
tex.set_magfilter(SamplerState.FT_nearest)
if any_filter:
tex.set_anisotropic_degree(8)
tex.set_wrap_u(SamplerState.WM_clamp)
tex.set_wrap_v(SamplerState.WM_clamp)
示例14: do_load
def do_load(self, filename):
""" Internal method to load the effect from the given filename, do
not use this directly, instead use load(). """
self.filename = filename
self.effect_name = self._convert_filename_to_name(filename)
self.effect_hash = self._generate_hash(filename, self._options)
# Load the YAML file
parsed_yaml = load_yaml_file(filename) or {}
self._parse_content(parsed_yaml)
# Construct a shader object for each pass
for pass_id in self._PASSES:
vertex_src = self._generated_shader_paths["vertex-" + pass_id]
fragment_src = self._generated_shader_paths["fragment-" + pass_id]
self._shader_objs[pass_id] = RPLoader.load_shader(vertex_src, fragment_src)
return True
示例15: _late_init
def _late_init(self, task):
""" Gets called after the pipeline initialized, this extracts the
exposure texture from the stage manager """
stage_mgr = self._pipeline.stage_mgr
if "Exposure" not in stage_mgr.pipes:
self.debug("Disabling exposure widget, could not find the exposure data.")
self._node.remove_node()
return
self._node.show()
exposure_tex = stage_mgr.pipes["Exposure"]
self._cshader = RPLoader.load_shader("/$$rp/shader/visualize_exposure.compute.glsl")
self._cshader_np.set_shader(self._cshader)
self._cshader_np.set_shader_input("DestTex", self._storage_tex)
self._cshader_np.set_shader_input("ExposureTex", exposure_tex)
return task.done