Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Post processing made easy

Author
Message
Toz
17
Years of Service
User Offline
Joined: 14th Oct 2007
Location: The Netherlands
Posted: 19th Jan 2008 15:37
A while ago I came up with the idea to make post processing effects like bloom and dof alot easier. I did this by making a bunch of functions that pretty much can take over any post processing effect. I offcourse don't expect you to understand the functions right away so here is the explanation:


scenerendertargetnumber = make_scene_render_target(sizex,sizey)
This function makes a rendertarget wich outputs a image of the current scene. You might wonder why you need more than one of these. Well useally, you don't. If you are only going to make a bloom effect then you don't need it. But if you are going into more complex effects, like dof for example, you will also need a extra scene with (in case of the dof) a distance shader applied to all the objects in the current viewport. The parameters sizex and sizey are the x and y resolution of the output image.


scene_render_to_target(rnt,srccam)
This function places the rendertarget camera at the position and angles of the source camera (srccam) and renders the scene to the output image of the rendertarget (rnt).


rendertargetnumber = make_render_target(img0,img1,img2,img3,img4,sizex,sizey,shd)
Unlike the make_scene_render_target function this doesn't render the scene but applies a shader to the image(s) specified and renders the result to another image. The img0,img1,img2,img3,img4 are the parameters for the input images. You at least have to specify img0. If the other 4 don't exist just specify a 0. Sizex and sizey are the x and y resolution of the output image. shd is the number of the effect that is going to be applied to the image(s).


render_to_target(srccam,rnt,tech$)
Renders the output images of a previously made rendertarget. srccam is the camera at wich the rendertarget camera will be positioned. rnt is the number of the rendertarget. tech$ is the name of a effect technique in the shader.


comp_final(shd,renderscene,img0,img1,img2,img3,img4,tech$)
This function can be considered as a make_render_target and render_to_target in only one function. Unlike render_to_target this function render to the screen and so is the final step in a post processing effect.


I made a example witch shows how to make a bloom effect. You can also see that I have included a shader in quite an unusual way.



Anyway I hope you guys find it most usefull. Have fun!

Don't read this, read the above.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 22nd Jan 2008 17:32
Sounds useful, but an example would be great to help indicate how these would be used, since I've never worked with post-processing shaders before.
Toz
17
Years of Service
User Offline
Joined: 14th Oct 2007
Location: The Netherlands
Posted: 24th Jan 2008 19:29
Well ectually the code snippet on the bottom of my post is the example. But if you didn't quite understood it here is the same example again with the commands in the main program (not the functions) explained better.



I hope the commands now make sens to you.

Don't read this, read the above.

Login to post a reply

Server time is: 2024-11-22 13:16:35
Your offset time is: 2024-11-22 13:16:35