本文整理汇总了Python中rpcore.RenderPipeline.set_effect方法的典型用法代码示例。如果您正苦于以下问题:Python RenderPipeline.set_effect方法的具体用法?Python RenderPipeline.set_effect怎么用?Python RenderPipeline.set_effect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rpcore.RenderPipeline
的用法示例。
在下文中一共展示了RenderPipeline.set_effect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import set_effect [as 别名]
class Application(ShowBase):
def __init__(self):
# Setup window size, title and so on
load_prc_file_data("", """
win-size 1600 900
window-title Render Pipeline - Material Sample
""")
self.render_pipeline = RenderPipeline()
self.render_pipeline.create(self)
# Set time of day
self.render_pipeline.daytime_mgr.time = "19:17"
# Load the scene
model = loader.load_model("scene/TestScene.bam")
model.reparent_to(render)
self.render_pipeline.prepare_scene(model)
# Enable parallax mapping on the floor
self.render_pipeline.set_effect(model.find("**/FloorPlane"),
"effects/default.yaml", {"parallax_mapping": True}, 100)
# Initialize movement controller
self.controller = MovementController(self)
self.controller.set_initial_position_hpr(
Vec3(-17.2912578583, -13.290019989, 6.88211250305),
Vec3(-39.7285499573, -14.6770210266, 0.0))
self.controller.setup()
示例2: World
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import set_effect [as 别名]
class World(ShowBase):
def __init__(self):
# Setup window size, title and so on
load_prc_file_data("", """
win-size 1600 900
window-title Render Pipeline - Roaming Ralph Demo
""")
# ------ Begin of render pipeline code ------
# Insert the pipeline path to the system path, this is required to be
# able to import the pipeline classes
pipeline_path = "../../"
# Just a special case for my development setup, so I don't accidentally
# commit a wrong path. You can remove this in your own programs.
if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
pipeline_path = "../../RenderPipeline/"
sys.path.insert(0, pipeline_path)
from rpcore import RenderPipeline, SpotLight
self.render_pipeline = RenderPipeline()
self.render_pipeline.create(self)
# ------ End of render pipeline code, thats it! ------
# Set time of day
self.render_pipeline.daytime_mgr.time = "7:40"
# Use a special effect for rendering the scene, this is because the
# roaming ralph model has no normals or valid materials
self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)
self.keyMap = {"left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0}
self.speed = 1.0
base.win.setClearColor(Vec4(0,0,0,1))
# Post the instructions
self.inst1 = addInstructions(0.95, "[ESC] Quit")
self.inst4 = addInstructions(0.90, "[W] Run Ralph Forward")
self.inst4 = addInstructions(0.85, "[S] Run Ralph Backward")
self.inst2 = addInstructions(0.80, "[A] Rotate Ralph Left")
self.inst3 = addInstructions(0.75, "[D] Rotate Ralph Right")
self.inst6 = addInstructions(0.70, "[Left Arrow] Rotate Camera Left")
self.inst7 = addInstructions(0.65, "[Right Arrow] Rotate Camera Right")
# Set up the environment
#
# This environment model contains collision meshes. If you look
# in the egg file, you will see the following:
#
# <Collide> { Polyset keep descend }
#
# This tag causes the following mesh to be converted to a collision
# mesh -- a mesh which is optimized for collision, not rendering.
# It also keeps the original mesh, so there are now two copies ---
# one optimized for rendering, one for collisions.
self.environ = loader.loadModel("resources/world")
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)
# Remove wall nodes
self.environ.find("**/wall").remove_node()
# Create the main character, Ralph
self.ralph = Actor("resources/ralph",
{"run":"resources/ralph-run",
"walk":"resources/ralph-walk"})
self.ralph.reparentTo(render)
self.ralph.setScale(.2)
self.ralph.setPos(Vec3(-110.9, 29.4, 1.8))
# Create a floater object. We use the "floater" as a temporary
# variable in a variety of calculations.
self.floater = NodePath(PandaNode("floater"))
self.floater.reparentTo(render)
# Accept the control keys for movement and rotation
self.accept("escape", sys.exit)
self.accept("a", self.setKey, ["left",1])
self.accept("d", self.setKey, ["right",1])
self.accept("w", self.setKey, ["forward",1])
self.accept("s", self.setKey, ["backward",1])
self.accept("arrow_left", self.setKey, ["cam-left",1])
self.accept("arrow_right", self.setKey, ["cam-right",1])
self.accept("a-up", self.setKey, ["left",0])
self.accept("d-up", self.setKey, ["right",0])
self.accept("w-up", self.setKey, ["forward",0])
self.accept("s-up", self.setKey, ["backward",0])
self.accept("arrow_left-up", self.setKey, ["cam-left",0])
self.accept("arrow_right-up", self.setKey, ["cam-right",0])
self.accept("=", self.adjustSpeed, [0.25])
#.........这里部分代码省略.........
示例3: Application
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import set_effect [as 别名]
class Application(ShowBase):
def __init__(self):
# Setup window size and title
load_prc_file_data(
"",
"""
# win-size 1600 900
window-title Render Pipeline - Instancing Example
""",
)
# Construct the render pipeline
self.render_pipeline = RenderPipeline()
self.render_pipeline.create(self)
self.render_pipeline.daytime_mgr.time = "19:17"
# self.render_pipeline.daytime_mgr.time = "12:00"
# Load the scene
model = self.loader.load_model("scene/Scene.bam")
model.reparent_to(self.render)
# Find the prefab object, we are going to in instance this object
# multiple times
prefab = model.find("**/InstancedObjectPrefab")
# Collect all instances
matrices = []
for elem in model.find_all_matches("**/PREFAB*"):
matrices.append(elem.get_mat(self.render))
elem.remove_node()
print("Loaded", len(matrices), "instances!")
# Allocate storage for the matrices, each matrix has 16 elements,
# but because one pixel has four components, we need amount * 4 pixels.
buffer_texture = Texture()
buffer_texture.setup_buffer_texture(len(matrices) * 4, Texture.T_float, Texture.F_rgba32, GeomEnums.UH_static)
float_size = len(struct.pack("f", 0.0))
floats = []
# Serialize matrices to floats
ram_image = buffer_texture.modify_ram_image()
for idx, mat in enumerate(matrices):
for i in range(4):
for j in range(4):
floats.append(mat.get_cell(i, j))
# Write the floats to the texture
data = struct.pack("f" * len(floats), *floats)
ram_image.set_subdata(0, len(data), data)
# Load the effect
self.render_pipeline.set_effect(prefab, "effects/basic_instancing.yaml", {})
prefab.set_shader_input("InstancingData", buffer_texture)
prefab.set_instance_count(len(matrices))
# We have do disable culling, so that all instances stay visible
prefab.node().set_bounds(OmniBoundingVolume())
prefab.node().set_final(True)
# Initialize movement controller, this is a convenience class
# to provide an improved camera control compared to Panda3Ds default
# mouse controller.
self.controller = MovementController(self)
self.controller.set_initial_position_hpr(Vec3(-23.2, -32.5, 5.3), Vec3(-33.8, -8.3, 0.0))
self.controller.setup()
示例4: App
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import set_effect [as 别名]
class App(ShowBase):
def __init__(self):
""" Inits the showbase """
# Load options
load_prc_file_data("", """
model-cache-dir
fullscreen #f
win-size 1920 1080
window-title Render Pipeline by tobspr
icon-filename dataGUI/icon.ico
""")
# Load render pipeline
self.render_pipeline = RenderPipeline(self)
self.render_pipeline.create()
# Init movement controller
self.controller = MovementController(self)
self.controller.set_initial_position_hpr(
Vec3(-987.129, -2763.58, 211.47), Vec3(5.21728, 7.84863, 0))
self.controller.setup()
# Hotkeys
self.accept("r", self._reload_shader)
self.addTask(self.update, "update")
self.scene_wireframe = False
self._init_terrain()
self._reload_shader()
def update(self, task):
""" Main update task """
self.terrain.update()
self.terrain_shadow.update()
return task.cont
def _reload_shader(self):
""" Reloads all terrain shaders """
self.render_pipeline.reload_shaders()
self.render_pipeline.set_effect(self.terrain.get_node(), "effects/terrain.yaml", {
"render_gbuffer": True,
"render_shadows": False,
})
self.render_pipeline.set_effect(self.terrain_shadow.get_node(), "effects/terrain_shadow.yaml", {
"render_gbuffer": False,
"render_shadows": True,
}, 5000)
def _init_terrain(self):
""" Inits the terrain """
layout = "Layout0"
hmap = "data/terrain/" + layout + "/heightmap.png"
bounds_file = "data/terrain/" + layout + "bounds.bin"
if not isfile(bounds_file):
print("Generating terrain bounds ..")
TerrainMeshRenderer.generate_bounds(hmap, "data/Terrain/" + layout + "bounds.bin")
terrainOffset = Vec3(-4096, -4096, 70.0)
terrainScale = Vec3(1.0, 1.0, 700.0)
self.terrain = TerrainMeshRenderer()
self.terrain.set_heightfield_size(8192)
self.terrain.set_culling_enabled(False)
self.terrain.load_chunk_mesh("core/resources/Chunk32.bam")
self.terrain.set_focus(base.cam, base.camLens)
self.terrain.load_bounds(bounds_file)
self.terrain.set_target_triangle_width(7.0)
self.terrain.set_pos(terrainOffset)
self.terrain.set_scale(terrainScale)
self.terrain.create()
node = self.terrain.get_node()
node.reparentTo(render)
self.terrain_shadow = TerrainMeshRenderer()
self.terrain_shadow.set_heightfield_size(8192)
self.terrain_shadow.load_chunk_mesh("core/resources/Chunk32.bam")
self.terrain_shadow.set_focus(base.cam, base.camLens)
self.terrain_shadow.set_target_triangle_width(7.0)
self.terrain_shadow.load_bounds(bounds_file)
self.terrain_shadow.set_pos(terrainOffset)
self.terrain_shadow.set_scale(terrainScale)
self.terrain_shadow.set_culling_enabled(False)
self.terrain_shadow.create()
nodeShadow = self.terrain_shadow.get_node()
nodeShadow.reparentTo(render)
#.........这里部分代码省略.........