def _CreateBasicRenderSteps(self): self.AddStep('UPDATE_SCENE', trinity.TriStepUpdate(self.GetScene())) self.AddStep('BEGIN_RENDER', trinity.TriStepRenderPass(self.GetScene(), trinity.TRIPASS_BEGIN_RENDER)) self.AddStep('END_RENDERING', trinity.TriStepRenderPass(self.GetScene(), trinity.TRIPASS_END_RENDER)) self.AddStep('RENDER_MAIN_PASS', trinity.TriStepRenderPass(self.GetScene(), trinity.TRIPASS_MAIN_RENDER)) self._CreateDepthPass() self._CreateBackgroundStep() self.AddStep('CLEAR', trinity.TriStepClear((0.0, 0.0, 0.0, 0.0), 1.0)) if self.clientToolsScene is not None: self.SetClientToolsScene(self.clientToolsScene.object)
def Initialize(self, size, speed, amplitude, tiling, texturePath): """ Initializes the output texture, render job, builds render steps. Returns the output texture. """ def TextureDestroyed(): """ Closure for weakref callback. Destroys the render job. """ self.Destroy() texture = trinity.Tr2RenderTarget(size, size, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM) self.name = 'Caustics' self.size = size self.texture = blue.BluePythonWeakRef(texture) self.texture.callback = TextureDestroyed self.steps.append(trinity.TriStepPushRenderTarget(texture)) self.steps.append(trinity.TriStepClear((0, 0, 0, 0))) self.steps.append(trinity.TriStepSetStdRndStates( trinity.RM_FULLSCREEN)) material = trinity.Tr2ShaderMaterial() material.highLevelShaderName = 'Caustics' param = trinity.TriTexture2DParameter() param.name = 'Texture' param.resourcePath = texturePath material.parameters['Texture'] = param param = trinity.Tr2FloatParameter() param.name = 'Speed' param.value = speed material.parameters['Speed'] = param param = trinity.Tr2FloatParameter() param.name = 'Amplitude' param.value = amplitude material.parameters['Amplitude'] = param param = trinity.Tr2FloatParameter() param.name = 'Tiling' param.value = tiling material.parameters['Tiling'] = param material.BindLowLevelShader([]) self.steps.append(trinity.TriStepRenderFullScreenShader(material)) self.steps.append(trinity.TriStepPopRenderTarget()) trinity.renderJobs.recurring.append(self) return trinity.TriTextureRes(texture)
def DoPrepareResources(self): if self.GetSwapChain(): self.AddStep( 'SET_RENDERTARGET', trinity.TriStepPushRenderTarget( self.GetSwapChain().backBuffer)) self.AddStep( 'SET_DEPTH', trinity.TriStepPushDepthStencil( self.GetSwapChain().depthStencilBuffer)) self.AddStep('RESTORE_RENDERTARGET', trinity.TriStepPopRenderTarget()) self.AddStep('RESTORE_DEPTH', trinity.TriStepPopDepthStencil()) self.AddStep('CLEAR', trinity.TriStepClear((0.0, 0.0, 0.0, 0.0), 1.0)) else: self.RemoveStep('SET_RENDERTARGET') self.RemoveStep('SET_DEPTH') self.RemoveStep('RESTORE_RENDERTARGET') self.RemoveStep('RESTORE_DEPTH')
def EnableFXAA(self, enable): self.fxaaEnabled = enable if not self.prepared: return if enable: if getattr(self, 'fxaaEffect', None) is None: self.fxaaEffect = trinity.Tr2ShaderMaterial() self.fxaaEffect.highLevelShaderName = 'PostProcess' self.fxaaEffect.defaultSituation = self.fxaaQuality self.fxaaEffect.BindLowLevelShader([]) self.AddStep('FXAA', trinity.TriStepRenderFullScreenShader(self.fxaaEffect)) if not self.usePostProcessing: self.AddStep('FXAA_CLEAR', trinity.TriStepClear((0, 0, 0, 1), 1.0)) self.RemoveStep('FINAL_BLIT') else: self.RemoveStep('FXAA') self.RemoveStep('FXAA_CLEAR') if not self.enabled: return self._CreateRenderTargets() self._RefreshRenderTargets()
def _CreateBasicRenderSteps(self): self.AddStep('UPDATE_SCENE', trinity.TriStepUpdate(self.GetScene())) self.AddStep('CLEAR', trinity.TriStepClear((0.0, 0.0, 0.0, 0.0), 1.0)) self.AddStep('RENDER_SCENE', trinity.TriStepRenderScene(self.GetScene()))
def EnableBackBufferClears(self, isEnabled): if isEnabled: self.AddStep('CLEAR', trinity.TriStepClear((0.0, 0.0, 0.0, 0.0), 1.0)) else: self.RemoveStep('CLEAR')
wxapp.ProcessPendingEvents() wxapp.ProcessIdle() uthread2.Yield() uthread2.StartTasklet(process_tasklet) def _on_video_info_ready(_, width, height): texture.__init__(width, height, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM) trinity.app.width = width trinity.app.height = height trinity.app.MoveWindow(trinity.app.left, trinity.app.top, trinity.app.width, trinity.app.height) video = videoplayer.VideoPlayer(blue.paths.open(path, 'rb'), videoplayer.WaveOutAudioSink()) texture = trinity.TriTextureRes() video.bgra_texture = texture video.on_create_textures = _on_video_info_ready app = TrinityApp(pauseOnDeactivate=False) init_wx(video) rj = trinity.TriRenderJob() rj.steps.append(trinity.TriStepSetStdRndStates(trinity.RM_ALPHA)) rj.steps.append(trinity.TriStepClear((0.3, 0.3, 0.3, 1), 1.0)) rj.steps.append(trinity.TriStepSetRenderState(27, 1)) rj.steps.append(trinity.TriStepRenderTexture(texture)) trinity.renderJobs.recurring.append(rj) app.exec_()