本文整理汇总了Python中shader.Shader.set_value方法的典型用法代码示例。如果您正苦于以下问题:Python Shader.set_value方法的具体用法?Python Shader.set_value怎么用?Python Shader.set_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shader.Shader
的用法示例。
在下文中一共展示了Shader.set_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import set_value [as 别名]
#.........这里部分代码省略.........
name = os.path.basename(mat)[:os.path.basename(mat).find('.')]
self.materials[name] = material
self.materials[os.path.basename(mat)] = material
# load object(s)
for obj in self.object_files:
ob = MeshObject(obj, self.texture_keys, self.materials)
ind = len(self.objects)
self.objects.append(ob)
name = os.path.basename(obj)[:os.path.basename(obj).find('.')]
self.object_keys[name] = ind
# initialize the framebuffers that we will render to
self._init_render()
self._init_shadow()
# some configuration
self.z_far = max(1.1, np.linalg.norm(np.array(self.cam_pos)) + 1.)
self.z_near = 0.05
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glDepthFunc(gl.GL_LEQUAL)
gl.glClearColor(0.1, 0.2, 0.3, 1.0)
# initialize the shaders
if self.shadows:
self.scene_shader = Shader(SCENE_VS_SHADER, SCENE_F_SHADER)
else:
self.scene_shader = Shader(SCENE_VS_SHADER, SCENE_F_SHADER_SIMPLE)
self.shadow_depth_shader = Shader(SHADOW_VS_SHADER, SHADOW_F_SHADER)
# shader configuration
self.scene_shader.use()
self._set_light()
self.scene_shader.set_value("shadowMap", 1)
self.scene_shader.set_value("diffuseTexture", 0)
def draw(self, position, rot, texture_ground, object_shape,
tip=None, texture_object='brushed_metal', light_pos=[0., 0.2, 1]):
"""
Renders the scene for a given configuration
Args:
position: object's position [in meter]
rot: object's rotation [in degree]
texture_ground: which texture to use for the table surface
object_shape: shape of the object
tip: the tip's position [optional]
texture_object: which texture to use for the object [default metal]
Returns:
im: RGB image of the scene (numpy array)
d: depth image of the scene (numpy array)
"""
gl.glClearDepth(1.)
# check the light position, should not be too far off for shadows
if self.shadows and np.linalg.norm(np.array(light_pos)) > 2.75:
log.warning('Light might be too far away from the scene for ' +
'proper shadow rendering!')
# get the light projection matrix
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
glu.gluPerspective(45., 1.0, self.z_near, 3.)
lightProjectionMatrix = gl.glGetFloatv(gl.GL_PROJECTION_MATRIX)