[LIBRARY] POSTER v0.3 - Post processing shaders made simple.

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

[LIBRARY] POSTER v0.3 - Post processing shaders made simple.

Post by veethree »

Hello! So i was working on some stuff and ended up completely abandoning it to go on a huge detour into shaders. That detour resulted in this library which i've decided to call POSTER. I want to say that the name stands for "Post processing On STERoids", Cause that would be quite clever, But i don't think this library lives up to such a name. So it's just POSTER. All caps for style.

It's kind of an extension to pp.lua which i made recently, But it comes with a collection of shaders and some more stuff. So its more akin to something like moonshine

It aims to make applying post processing shaders to your game straight forward, While being pretty flexible.

As usually, It's properly documented over on github. It's a bit of a work in progress, I'd love it if you could try it out, And let me know what features it's missing and whats broken etc.

First, Here's what it can do:
Turn this garbage
SnakeDemoNoShaders.gif
SnakeDemoNoShaders.gif (123.98 KiB) Viewed 7025 times
Into this
SnakeDemoShaders.gif
SnakeDemoShaders.gif (462.82 KiB) Viewed 7025 times
Which i think we can all agree looks better :)


Basic usage:
Load it:

Code: Select all

poster = require("poster")
Make a canvas:

Code: Select all

canvas = poster.new() -- I should probably rename this to "newCanvas". Just realized.
Draw your game, Or whatever you want to the canvas like

Code: Select all

canvas:drawTo(function()
-- Draw stuff
end)
or

Code: Select all

canvas:set()
-- Draw stuff
canvas:unset()
Draw your canvas and apply lovely post processing shaders to the canvas like:

Code: Select all

canvas:draw("rgbMix", "saturation", "verticalBlur")
The draw function can either take a mix of strings, Referencing the built in shaders and/or references to your own shaders, Or chains, Which i'll get to in a moment

To control the built in shaders, You need to send them some uniforms(externs), Which shaders need what uniforms exactly is also explained on github. To send data to shaders you use the following funciton:

Code: Select all

poster:send(shader, uniform, data)
where shader is a string, Referencing the shader, Uniform is also a string, Referencing the specific uniform, And data is the data.
You can also pass it a table with a format like

Code: Select all

{
{shader, uniform, data},
{shader, uniform, data},
{shader, uniform, data},
...
}
But those uniforms will be global, A better way is using the aforementioned chains. Which i'll explain now.
To create a new chain you can either

Code: Select all

blur = poster.newChain({"verticalBlur", "horizontalBlur"}, {{"verticalBlur", "amount", 3}, {"horizontalBlur", "amount", 3}})

Or a slightly "cleaner" but less compact

Code: Select all

blur = poster.
blur:addShader("verticalBlur", "horizontalBlur")
blur:addSetting("verticalBlur", "amount", 3)
blur:addSetting("horizontalBlur", "amount", 3)
Or some combination of the 2 methods
Then you apply the chains with the draw function

Code: Select all

canvas:draw(blur)

One thing that's obviously missing from this at the moment is a way to animate chained shaders, I have some ideas for that that i still have to iron out. It's pretty easy to do so globally, Just continuously update a uniform with poster:send(). If you have any other ideas for features or changes, I'm all ears. Thank you!

EDIT: I think i've fixed the issue of not being able to animate chained shaders. I added "macros" to the chain system. You can define a macro like this:

Code: Select all

chain:addMacro(macroName, Targets)
Where macroName is the name used to refer to the macro, And targets is a table like

Code: Select all

{
	{shader, uniform, multiplier},
	{shader, uniform, multiplier},
	...
}
Then you can control the macro with

Code: Select all

chain:setMacro(macroName, value)
Attachments
POSTERv0.3.zip
(8.15 KiB) Downloaded 166 times
POSTER_DEMO_SNAKE.love
(17.65 KiB) Downloaded 181 times
Last edited by veethree on Fri Oct 08, 2021 12:45 pm, edited 2 times in total.
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: POSTER - Post processing shaders made simple.

Post by yetneverdone »

This is really cool! Ive taken a look at the source files and it's written nicely and does not suffer from the issues that moonshine does!
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: POSTER - Post processing shaders made simple.

Post by veethree »

yetneverdone wrote: Tue Oct 05, 2021 11:50 pm This is really cool! Ive taken a look at the source files and it's written nicely and does not suffer from the issues that moonshine does!
What issues does moonshine have? I've never properly used it but the few times i messed around with it i didn't notice any issues
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: POSTER - Post processing shaders made simple.

Post by yetneverdone »

What issues does moonshine have? I've never properly used it but the few times i messed around with it i didn't notice any issues
One thing I actually saw in the source code of moonshine is that shader codes are compiled so passing dynamic values to a shader there requires recompiling the shader which is very slow. Also managing the canvas used internally is difficult.
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: [LIBRARY] POSTER v0.3 - Post processing shaders made simple.

Post by veethree »

New version. It previously had issues when the canvas had transparent sections. Now those are impossible. Also i've made a more sensible demo which is an actual game now, instead of just a stock photo, Which is the intended use case for this. The demo also showcases how to animate macros, Which the previous demo did not.
Post Reply

Who is online

Users browsing this forum: targetcreature and 62 guests