Jump to content

Post Filter Effect in Lua


smishra
 Share

Recommended Posts

I had earlier created post filter effects in BlitzMax by modifying the Framework Renderer and they work great.

 

I have since got hooked onto the editor and the ability to run the environment directly in the editor. This is of great help to the scene designers. In order to design good scenes which employ custom post filter effects, we need to be able to run the post filter effects from the editor.

 

Is it possible to add custom post filter effects using lua. The Framework is now compiled into the engine. If there ware 2-3 slots available for custom shaders and custom filters it would be great. We could enable custom filter effect, the same way as we enable other filter effects. By default these custom filters would do nothing.

Link to comment
Share on other sites

There are several ways to achieve this:

1) either replace one of the shaders (like the SSAO) with your own in the shaders.pak and turn it on/off using the Tools>Options settings

2) replace all the normal shaders (like shown here )

3) create a lua script that sets the postfilter shader... keep in mind lua has issues with loading some shaders due to some function overwrite issues as noted here

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thanks for your suggestions.

 

Right now, approach 1, replacing a couple of unused postfilter effects with custom effects seems the path of least resistance. However it is a hack. In some scenes the designer may want to use the effects that I have overwrriten.

 

We use a few of the built in post filter effects, so replacing the entire shaders.pak will not be effective.

 

In approach 3, is there an easy way to access the CurrentBuffer() in the shader. I tried getting the current buffer in Lua and binding it, but got an Exception error.

 

In the long term, making the Framewerk more flexible may be the best option. One way would be to make the list of postfilters an expandable one, that can be added to from Lua itself. If it is not too much of a performance drag, coding the renderer in Lua might work out.

 

 

 

 

There are several ways to achieve this:

1) either replace one of the shaders (like the SSAO) with your own in the shaders.pak and turn it on/off using the Tools>Options settings

2) replace all the normal shaders (like shown here )

3) create a lua script that sets the postfilter shader... keep in mind lua has issues with loading some shaders due to some function overwrite issues as noted here

Link to comment
Share on other sites

Right now, approach 1, replacing a couple of unused postfilter effects with custom effects seems the path of least resistance. However it is a hack. In some scenes the designer may want to use the effects that I have overwrriten.

 

yes a bit of hack... and just as a side note, i hope your designers all have a SDK license as well...

 

In approach 3, is there an easy way to access the CurrentBuffer() in the shader. I tried getting the current buffer in Lua and binding it, but got an Exception error.

 

In the long term, making the Framewerk more flexible may be the best option. One way would be to make the list of postfilters an expandable one, that can be added to from Lua itself. If it is not too much of a performance drag, coding the renderer in Lua might work out.

 

Well the problem is the fact that the CurrentBuffer() could be grabbing any of the several buffers... you would have to be more specific. Using lua to load the postfilter would be ideal... as long as there were no conflicting functions in your shader.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I ended up doing a custom post filter after rendering using built in postfilter. Textures 9 and 10 seem to work for passing textures from the Lua program to custom shader.

 

SetBuffer(opticsBuffer)

fw:Render()

SetBuffer(BackBuffer())

SaveBuffer(opticsBuffer,"ob.jpg",85)

filter_nvg = LoadShader("abstract::nvg.vert", "abstract::nvg.frag")

SetShader(filter_nvg)

BindTexture(GetColorBuffer(opticsBuffer,0), 9)

 

 

 

 

 

 

 

 

 

yes a bit of hack... and just as a side note, i hope your designers all have a SDK license as well...

 

 

 

Well the problem is the fact that the CurrentBuffer() could be grabbing any of the several buffers... you would have to be more specific. Using lua to load the postfilter would be ideal... as long as there were no conflicting functions in your shader.

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.

 Share

×
×
  • Create New...