本文整理汇总了Python中panda3d.core.PNMImage.set_gray方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.set_gray方法的具体用法?Python PNMImage.set_gray怎么用?Python PNMImage.set_gray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PNMImage
的用法示例。
在下文中一共展示了PNMImage.set_gray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_star
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_gray [as 别名]
def make_star(name='star', scale=1, color=Vec3(1), texture_size=64, debug=False):
card_maker = CardMaker(name)
card_maker.set_frame(-1, 1, -1, 1)
node_path = NodePath(name)
node = card_maker.generate()
final_node_path = node_path.attach_new_node(node)
final_node_path.set_billboard_point_eye()
from panda3d.core import Filename
shaders = Shader.load(Shader.SL_GLSL,
Filename('Shader/Star/vertex.glsl'),
Filename('Shader/Star/fragment.glsl'),
Filename(''),
Filename(''),
Filename(''))
if not shaders:
print("WARNING. STAR SHADER FAILED TO LOAD", type(shaders))
else:
final_node_path.set_shader_input('cameraSpherePos', 1, 1, 1)
final_node_path.set_shader_input('sphereRadius', 1.0)
final_node_path.set_shader_input('myCamera', base.camera)
final_node_path.set_shader(shaders)
final_node_path.set_shader_input('blackbody', color)
material = Material()
material.set_emission(VBase4(color, 1.0))
final_node_path.set_material(material)
xn = PerlinNoise3(0.5, 0.5, 0.5)
#yn = PerlinNoise3(0.5, 0.5, 0.5)
texture = Texture('star')
texture.setup_3d_texture()
for z in range(texture_size):
p = PNMImage(texture_size, texture_size)
for y in range(texture_size):
for x in range(texture_size):
p.set_gray(x, y, abs(xn.noise(x, y, z)))
texture.load(p, z, 0)
diffuse = texture
diffuse.setMinfilter(Texture.FTLinearMipmapLinear)
diffuse.setAnisotropicDegree(4)
final_node_path.set_texture(diffuse)
normal = sandbox.base.loader.loadTexture('data/empty_textures/empty_normal.png')
normalts = TextureStage('normalts')
final_node_path.set_texture(normalts, normal)
specular = sandbox.base.loader.loadTexture('data/empty_textures/empty_specular.png')
spects = TextureStage('spects')
final_node_path.set_texture(spects, specular)
roughness = sandbox.base.loader.loadTexture('data/empty_textures/empty_roughness.png')
roughts= TextureStage('roughts')
final_node_path.set_texture(roughts, roughness)
return final_node_path
示例2: make_star
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_gray [as 别名]
def make_star(name='star', scale=1, color=Vec3(1), texture_size=64, debug=False):
card_maker = CardMaker(name)
card_maker.set_frame(-1, 1, -1, 1)
node_path = NodePath(name)
node = card_maker.generate()
final_node_path = node_path.attach_new_node(node)
final_node_path.set_billboard_point_eye()
shaders = Shader.load(Shader.SLGLSL,
'Shader/Star/vertex.glsl',
'Shader/Star/fragment.glsl')
final_node_path.set_shader_input(b'cameraSpherePos', 1, 1, 1)
final_node_path.set_shader_input(b'sphereRadius', 1.0)
final_node_path.set_shader_input(b'myCamera', base.camera)
final_node_path.set_shader(shaders)
final_node_path.set_shader_input(b'blackbody', color)
material = Material()
material.set_emission(VBase4(color, 1.0))
final_node_path.set_material(material)
xn = PerlinNoise3(0.5, 0.5, 0.5)
#yn = PerlinNoise3(0.5, 0.5, 0.5)
texture = Texture('star')
texture.setup_3d_texture()
for z in range(texture_size):
p = PNMImage(texture_size, texture_size)
for y in range(texture_size):
for x in range(texture_size):
p.set_gray(x, y, abs(xn.noise(x, y, z)))
texture.load(p, z, 0)
diffuse = texture
diffuse.setMinfilter(Texture.FTLinearMipmapLinear)
diffuse.setAnisotropicDegree(4)
final_node_path.set_texture(diffuse)
normal = base.loader.loadTexture('Data/Textures/EmptyNormalTexture.png')
normalts = TextureStage('normalts')
final_node_path.set_texture(normalts, normal)
specular = base.loader.loadTexture('Data/Textures/EmptySpecularTexture.png')
spects = TextureStage('spects')
final_node_path.set_texture(spects, specular)
roughness = base.loader.loadTexture('Data/Textures/EmptyRoughnessTexture.png')
roughts= TextureStage('roughts')
final_node_path.set_texture(roughts, roughness)
return final_node_path