示例#1
0
	def _swayOnPlant(self, swayAnimation, plant, amp_x, amp_y, freq_x, freq_y, timeOffset, billboard2D=False, billboard3D=False):
		"""Apply the sway animation to each plant."""
		
		if swayAnimation is True:
			plant.apply(self._swayEffect)
			
			amp_XUniform = viz.addUniformFloat('Amp_X', amp_x)
			plant.apply(amp_XUniform)
			
			amp_YUniform = viz.addUniformFloat('Amp_Y', amp_y)
			plant.apply(amp_YUniform)
			
			freq_XUniform = viz.addUniformFloat('Freq_X', freq_x)
			plant.apply(freq_XUniform)

			freq_YUniform = viz.addUniformFloat('Freq_Y', freq_y)
			plant.apply(freq_YUniform)	
			
			timeOffsetUniform = viz.addUniformFloat('TimeOffset', timeOffset)
			plant.apply(timeOffsetUniform)
		
		if billboard2D is True:
			plant.billboard(viz.BILLBOARD_YAXIS)
		
		elif billboard3D is True:
			plant.billboard(viz.BILLBOARD_VIEW_POS)
示例#2
0
    def __init__(self):
        # open the fragment shader, assuming it's relative to this code file
        vertCode = ""
        with open(
                os.path.join(os.path.dirname(__file__), 'view_projector.vert'),
                'r') as vertFile:
            vertCode = vertFile.read()
        fragCode = ""
        with open(
                os.path.join(os.path.dirname(__file__), 'view_projector.frag'),
                'r') as fragFile:
            fragCode = fragFile.read()

        # Make a new shader, and assign some default values for the uniforms.
        # Thesewill be replaced on update.
        self._shader = viz.addShader(frag=fragCode, vert=vertCode)

        # temp mat to default set the uniforms
        mat = vizmat.Transform()

        # Holds the inverse transform of the main view.
        # This will help to calculate the model matrix inside the shader.
        # Such that vertices can be re-projected into view space of the projector.
        self._inv_view_uni = viz.addUniformMatrix('mainViewMat_inv', mat.get())

        # View matrix of the projector.
        self._view_uni = viz.addUniformMatrix('viewMat', mat.get())

        # Projection matrix of the projector.
        self._proj_uni = viz.addUniformMatrix('projMat', mat.get())

        # Holds the depth texture to perform inverse shadow mapping.
        # This will allow for projecting only onto first fragment hit.
        self._depth_texture_uni = viz.addUniformInt('depth_tex', 3)

        # This allows for accumulation of the previous frames projection
        # along with the actual frames projection.
        self._prev_texture_uni = viz.addUniformInt('prev_frame_tex', 4)

        # specifies an additional scaling factor for frame based accumulation (value range [0.1,1.0])
        self._frame_weight_uni = viz.addUniformFloat('frame_weight', 1.0)

        # specifies a scaling factor for the view cone aperture (value range [0.0,1.0])
        self._aperture_scale_uni = viz.addUniformFloat('aperture_scale', 1.0)

        # attach all uniforms
        self._shader.attach([
            self._inv_view_uni, self._view_uni, self._proj_uni,
            self._depth_texture_uni, self._prev_texture_uni,
            self._frame_weight_uni, self._aperture_scale_uni
        ])

        # Camera used to capture the depth texture.
        self._depth_cam = viz.addRenderNode(inheritView=False)
        self._depth_cam.drawOrder(1000)
        self._depth_cam.setAutoClip(False)
        self._depth_cam.setRenderTexture(
            viz.addRenderTexture(format=viz.TEX_DEPTH),
            buffer=viz.RENDER_DEPTH)
示例#3
0
def createBlendShader1():
	global shader, algaeBlend, TextureUnit1Uniform, TextureUnit2Uniform
	shader = viz.addShader(frag='texBlend.frag')
	algaeBlend = viz.addUniformFloat('BlendAmount', 0)
	TextureUnit1Uniform = viz.addUniformInt('TextureUnit1', 0)
	TextureUnit2Uniform = viz.addUniformInt('TextureUnit2', 1)