HugoMcPhee Posted March 30, 2015 Share Posted March 30, 2015 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 itHere'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? Quote Link to comment Share on other sites More sharing options...
HugoMcPhee Posted March 30, 2015 Author Share Posted March 30, 2015 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); DiV and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.