本文整理汇总了Python中panda3d.core.PNMImage.gaussian_filter方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.gaussian_filter方法的具体用法?Python PNMImage.gaussian_filter怎么用?Python PNMImage.gaussian_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PNMImage
的用法示例。
在下文中一共展示了PNMImage.gaussian_filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_cubemap
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import gaussian_filter [as 别名]
def filter_cubemap(orig_pth):
if not os.path.isdir("Filtered/"):
os.makedirs("Filtered/")
# Copy original cubemap
for i in range(6):
shutil.copyfile(orig_pth.replace("#", str(i)), "Filtered/0-" + str(i) + ".png")
mip = 0
while True:
print("Filtering mipmap", mip)
mip += 1
pth = "Filtered/" + str(mip - 1) + "-#.png"
dst_pth = "Filtered/" + str(mip) + "-#.png"
first_img = load_nth_face(pth, 0)
size = first_img.get_x_size() // 2
if size < 1:
break
blur_size = size * 0.002
blur_size += mip * 0.85
blur_size = int(blur_size)
effective_size = size + 2 * blur_size
faces = [load_nth_face(pth, i) for i in range(6)]
cubemap = loader.loadCubeMap(pth)
node = NodePath("")
node.set_shader(compute_shader)
node.set_shader_input("SourceCubemap", cubemap)
node.set_shader_input("size", size)
node.set_shader_input("blurSize", blur_size)
node.set_shader_input("effectiveSize", effective_size)
final_img = PNMImage(size, size, 3)
for i in range(6):
face_dest = dst_pth.replace("#", str(i))
dst = Texture("Face-" + str(i))
dst.setup_2d_texture(effective_size, effective_size,
Texture.T_float, Texture.F_rgba16)
# Execute compute shader
node.set_shader_input("faceIndex", i)
node.set_shader_input("DestTex", dst)
attr = node.get_attrib(ShaderAttrib)
base.graphicsEngine.dispatch_compute(( (effective_size+15) // 16,
(effective_size+15) // 16, 1),
attr, base.win.get_gsg())
base.graphicsEngine.extract_texture_data(dst, base.win.get_gsg())
img = PNMImage(effective_size, effective_size, 3)
dst.store(img)
img.gaussian_filter(blur_size)
final_img.copy_sub_image(img, 0, 0, blur_size, blur_size, size, size)
final_img.write(face_dest)