本文整理汇总了Python中rpcore.RenderPipeline.reload_shaders方法的典型用法代码示例。如果您正苦于以下问题:Python RenderPipeline.reload_shaders方法的具体用法?Python RenderPipeline.reload_shaders怎么用?Python RenderPipeline.reload_shaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rpcore.RenderPipeline
的用法示例。
在下文中一共展示了RenderPipeline.reload_shaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainApp
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import reload_shaders [as 别名]
class MainApp(ShowBase):
def __init__(self):
# Setup window size, title and so on
load_prc_file_data("", """
win-size 1600 900
window-title Render Pipeline - Shading Models 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)
# This is a helper class for better camera movement - its not really
# a rendering element, but it included for convenience
from rpcore.util.movement_controller import MovementController
# ------ End of render pipeline code, thats it! ------
# Set time of day
self.render_pipeline.daytime_mgr.time = 0.769
# Load the scene
model = loader.loadModel("scene/TestScene.bam")
model.reparent_to(render)
self.render_pipeline.prepare_scene(model)
# Init movement controller
self.controller = MovementController(self)
self.controller.set_initial_position(
Vec3(6.6, -18.8, 4.5), Vec3(4.7, -16.7, 3.4))
self.controller.setup()
base.accept("l", self.tour)
base.accept("r", self.reload_shaders)
def reload_shaders(self):
self.render_pipeline.reload_shaders()
self.render_pipeline.prepare_scene(render)
def tour(self):
mopath = (
(Vec3(3.97601628304, -15.5422525406, 1.73230814934), Vec3(49.2462043762, -11.7619161606, 0.0)),
(Vec3(4.37102460861, -6.52981519699, 2.84148645401), Vec3(138.54864502, -15.7908058167, 0.0)),
(Vec3(-5.88968038559, -13.9816446304, 2.44033527374), Vec3(302.348571777, -13.2863616943, 0.0)),
(Vec3(5.23844909668, -18.1897411346, 4.54698801041), Vec3(402.91229248, -14.7019147873, 0.0)),
(Vec3(-7.27328443527, -0.466051012278, 3.30696845055), Vec3(607.032165527, -19.6019115448, 0.0)),
(Vec3(5.33415555954, 1.92750489712, 2.53945565224), Vec3(484.103546143, -11.9796953201, 0.0)),
(Vec3(-0.283608138561, -6.86583900452, 1.43702816963), Vec3(354.63848877, -4.79302883148, 0.0)),
(Vec3(-11.7576808929, 7.0855755806, 3.40899515152), Vec3(272.73840332, -12.959692955, 0.0)),
(Vec3(7.75462722778, 13.220041275, 3.97876667976), Vec3(126.342140198, -19.4930171967, 0.0)),
(Vec3(-2.10827493668, 4.78230571747, 1.27567899227), Vec3(-40.1353683472, -5.77301359177, 0.0)),
(Vec3(8.67115211487, 16.9084873199, 3.72598099709), Vec3(89.5658569336, -10.9996757507, 0.0)),
(Vec3(-8.1254825592, 26.6411190033, 3.21335697174), Vec3(268.092102051, -12.1974525452, 0.0)),
(Vec3(7.89382314682, 45.8911399841, 4.47727441788), Vec3(498.199554443, -11.3263425827, 0.0)),
(Vec3(-2.33054184914, 43.8977775574, 1.86498868465), Vec3(551.198242188, 13.6092195511, 0.0)),
(Vec3(4.80335664749, 36.9664497375, 6.16300296783), Vec3(810.128417969, -10.6730031967, 0.0)),
(Vec3(45.0654678345, 7.54712438583, 22.2645874023), Vec3(808.238586426, -17.5330123901, 0.0)),
(Vec3(5.99377584457, -12.3760728836, 4.53536558151), Vec3(806.978820801, -2.39745855331, 0.0)),
(Vec3(6.05853939056, -1.72227275372, 4.53848743439), Vec3(809.65637207, -2.39745855331, 0.0)),
(Vec3(4.81568479538, 8.28769683838, 4.48393821716), Vec3(809.65637207, -2.39745855331, 0.0)),
(Vec3(5.82831144333, 17.5230751038, 4.52401590347), Vec3(809.65637207, -2.39745855331, 0.0)),
(Vec3(4.09594917297, 26.7909412384, 4.44915866852), Vec3(809.65637207, -2.39745855331, 0.0)),
(Vec3(4.39108037949, 37.2143096924, 5.16932630539), Vec3(809.65637207, -2.39745855331, 0.0)),
)
self.controller.play_motion_path(mopath, 2.3)
示例2: Application
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import reload_shaders [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 by tobspr
stm-max-chunk-count 2048
gl-coordinate-system default
stm-max-views 20
notify-level-linmath error
""")
self.render_pipeline = RenderPipeline()
self.render_pipeline.create(self)
# Set time of day
self.render_pipeline.daytime_mgr.time = "04:25"
# Add some environment probe to provide better reflections
probe = self.render_pipeline.add_environment_probe()
probe.set_pos(0, 0, 600)
probe.set_scale(8192 * 2, 8192 * 2, 1000)
self.terrain_np = render.attach_new_node("terrain")
heightfield = loader.loadTexture("resources/heightfield.png")
for x in range(3):
for y in range(3):
terrain_node = ShaderTerrainMesh()
terrain_node.heightfield = heightfield
terrain_node.target_triangle_width = 6.0
terrain_node.generate()
terrain_n = self.terrain_np.attach_new_node(terrain_node)
terrain_n.set_scale(8192, 8192, 600)
terrain_n.set_pos(-4096 + (x - 1) * 8192, -4096 + (y - 1) * 8192, 0)
# Init movement controller
self.controller = MovementController(self)
self.controller.set_initial_position(Vec3(-12568, -11736, 697), Vec3(-12328, -11357, 679))
self.controller.setup()
self.accept("r", self.reload_shaders)
self.reload_shaders()
def reload_shaders(self):
self.render_pipeline.reload_shaders()
# Set the terrain effect
self.render_pipeline.set_effect(self.terrain_np, "effects/terrain-effect.yaml", {}, 100)
base.accept("l", self.tour)
def tour(self):
control_points = (
(Vec3(2755.62084961, 6983.76708984, 506.219055176), Vec3(-179.09147644, 4.30751991272, 0.0)),
(Vec3(3153.70068359, 5865.30859375, 560.780822754), Vec3(-225.239028931, 3.43641376495, 0.0)),
(Vec3(2140.57080078, 5625.22753906, 598.345031738), Vec3(-196.022613525, 1.91196918488, 0.0)),
(Vec3(2598.85961914, 3820.56958008, 627.692993164), Vec3(-272.410125732, 3.32752752304, 0.0)),
(Vec3(1894.64526367, 3597.39257812, 647.455078125), Vec3(-198.227630615, 0.605303645134, 0.0)),
(Vec3(1998.48425293, 1870.05358887, 639.38458252), Vec3(-121.682502747, 0.169744253159, 0.0)),
(Vec3(3910.55297852, 2370.70922852, 518.356567383), Vec3(-130.42376709, 3.65418696404, -0.000583928485867)),
(Vec3(4830.80761719, 1542.30749512, 501.019073486), Vec3(21.7212314606, 8.00974178314, 0.0)),
(Vec3(4324.81982422, 2259.2409668, 713.095458984), Vec3(-19.1500263214, -1.68137300014, 0.0)),
(Vec3(4584.38720703, 3417.75073242, 612.79510498), Vec3(-39.4675331116, -4.94804239273, 0.0)),
(Vec3(4569.68261719, 4840.80908203, 540.924926758), Vec3(-83.4887771606, 4.08973407745, 0.0)),
(Vec3(5061.6484375, 5490.93896484, 694.142578125), Vec3(-135.778717041, 0.605291008949, 0.0)),
(Vec3(6273.03222656, 6343.10546875, 769.735290527), Vec3(-200.826278687, -1.35470712185, 0.0)),
(Vec3(7355.02832031, 6314.39892578, 1164.65527344), Vec3(-262.645324707, -12.2435855865, 0.0)),
(Vec3(6321.42431641, 4453.68310547, 898.895202637), Vec3(-322.574157715, -2.22581481934, 0.0)),
(Vec3(4820.63916016, 4637.07128906, 793.165222168), Vec3(-330.291748047, 0.931967377663, 0.0)),
(Vec3(2621.3125, 4790.99072266, 691.223144531), Vec3(-423.059020996, 3.10974740982, 0.0)),
(Vec3(2166.64697266, 5683.75195312, 685.415039062), Vec3(-497.871612549, -1.57248008251, 0.0)),
(Vec3(2426.64135742, 7216.48974609, 993.247558594), Vec3(-524.17388916, -6.69025611877, 0.0)),
(Vec3(5014.83398438, 6712.60253906, 963.192810059), Vec3(-596.072387695, -3.31469583511, 0.00446693599224)),
(Vec3(6107.69970703, 5460.03662109, 820.63104248), Vec3(-650.567199707, 1.04085958004, 0.0)),
)
self.controller.play_motion_path(control_points, 3.0)
示例3: Application
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import reload_shaders [as 别名]
class Application(ShowBase):
def __init__(self):
sys.path.insert(0, "../../")
load_prc_file_data("", "win-size 512 512")
load_prc_file_data("", "textures-power-2 none")
load_prc_file_data("", "print-pipe-types #f")
load_prc_file_data("", "notify-level-glgsg error")
# load_prc_file_data("", "win-size 1024 1024")
from rpcore import RenderPipeline, PointLight
self.render_pipeline = RenderPipeline()
self.render_pipeline.mount_mgr.config_dir = "config/"
self.render_pipeline.set_empty_loading_screen()
self.render_pipeline.create(self)
sphere = loader.loadModel("res/sphere.bam")
sphere.reparent_to(render)
self.disableMouse()
self.camLens.setFov(40)
self.camLens.setNearFar(0.03, 2000.0)
self.camera.set_pos(0, -3.5, 0)
self.camera.look_at(0, -2.5, 0)
self.render2d.hide()
self.aspect2d.hide()
light = PointLight()
light.pos = 10, -10, 10
light.radius = 1e20
light.color = (1, 1, 1)
light.inner_radius = 4.0
light.energy = 3
self.render_pipeline.add_light(light)
light = PointLight()
light.pos = -10, -10, 10
light.radius = 1e20
light.color = (1, 1, 1)
light.inner_radius = 4.0
light.energy = 3
self.render_pipeline.add_light(light)
for mat in sphere.find_all_materials():
mat.roughness = material.roughness
mat.base_color = Vec4(*(list(material.basecolor) + [1]))
mat.refractive_index = material.ior
mat.metallic = 1.0 if material.mat_type == "metallic" else 0.0
if material.mat_type == "clearcoat":
mat.emission = (2, 0, 0, 0)
mat.metallic = 1.0
mat.refractive_index = 1.51
if material.mat_type == "foliage":
mat.emission = (5, 0, 0, 0)
mat.metallic = 0.0
mat.refractive_index = 1.51
for i in range(10):
self.taskMgr.step()
self.win.save_screenshot("scene-rp.png")
base.accept("r", self.reload)
def reload(self):
print("Reloading")
self.render_pipeline.reload_shaders()
for i in range(4):
self.taskMgr.step()
self.win.save_screenshot("scene-rp.png")
示例4: App
# 需要导入模块: from rpcore import RenderPipeline [as 别名]
# 或者: from rpcore.RenderPipeline import reload_shaders [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)
#.........这里部分代码省略.........