Jump to content

Apply a post process to a RenderTargetTexture


HugoMcPhee
 Share

Recommended Posts

I'm trying to show a render target texture on a plane that shows a post processed version of the scene.
I can get the render target texture to draw the scene to the plane, but I can't get a post effect to work on it

Here's my example code
 

            var postProcessConvolution;            var renderTarget = new BABYLON.RenderTargetTexture("depth", 1024, newScene,false, true);            newScene.customRenderTargets.push(renderTarget);            renderTarget.renderList = newScene.meshes;            renderTarget.onBeforeRender = function () {                postProcessConvolution = new BABYLON.ConvolutionPostProcess("convolution", BABYLON.ConvolutionPostProcess.EdgeDetect2Kernel, 0.7, mainCamera);            }            renderTarget.onAfterRender = function () {                postProcessConvolution.dispose();            }

I thought it would apply the process, then render the texture, then dispose the post process. 
Without the .dispose() the post process is applied to the whole scene every frame.

has anyone succesfully done this before?
 

Link to comment
Share on other sites

Instead of trying to use a post process, I just used the fragment shader part (.fragment.fx) from the posteffect in a new "ShaderMaterial" and applied that onto the plane, then I passed the renderTargetTexture to that ShaderMaterial and the effect was the same.

Here's what the final code was
 

var kalideMaterial = new BABYLON.ShaderMaterial("kalideShader", newScene, "./kalideMat",{    attributes: ["position", "uv"],    uniforms: ["worldViewProjection"]});backBackDrop.material = kalideMaterial;kalideMaterial.setTexture("textureSampler", renderTarget);
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...