LumixEngine/data/pipelines/film_grain.lua

35 lines
901 B
Lua
Raw Normal View History

2018-10-13 00:09:34 +02:00
function postprocess(env, transparent_phase, ldr_buffer, gbuffer0, gbuffer1, gbuffer_depth, shadowmap)
if not enabled then return ldr_buffer end
if transparent_phase ~= "post_tonemap" then return ldr_buffer end
2019-07-06 14:52:14 +02:00
local res = env.createRenderbuffer(1, 1, true, "rgba8", "film_grain")
2018-10-13 00:09:34 +02:00
env.beginBlock("film_grain")
if env.film_grain_shader == nil then
env.film_grain_shader = env.preloadShader("pipelines/film_grain.shd")
2018-10-13 00:09:34 +02:00
end
2019-10-06 16:57:48 +02:00
env.setRenderTargets(res)
env.drawArray(0, 4, env.film_grain_shader,
2019-07-06 14:52:14 +02:00
{ ldr_buffer },
{},
{},
{ depth_test = false, blending = ""}
)
2018-10-13 00:09:34 +02:00
env.endBlock()
return res
end
function awake()
if _G["postprocesses"] == nil then
_G["postprocesses"] = {}
end
table.insert(_G["postprocesses"], postprocess)
end
function onDestroy()
for i, v in ipairs(_G["postprocesses"]) do
if v == postprocess then
table.remove(_G["postprocesses"], i)
break;
end
end
end