{"id":13300124,"url":"https://github.com/Jerakin/defold-post-process-example","last_synced_at":"2025-03-10T11:32:52.635Z","repository":{"id":129089865,"uuid":"608762087","full_name":"Jerakin/defold-post-process-example","owner":"Jerakin","description":"Example on how to do a full screen post process effect","archived":false,"fork":false,"pushed_at":"2023-03-03T00:17:25.000Z","size":1232,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T17:50:33.687Z","etag":null,"topics":["blur","defold","example","postprocess"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jerakin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-02T17:25:17.000Z","updated_at":"2024-03-10T10:00:47.000Z","dependencies_parsed_at":"2023-03-25T21:08:16.322Z","dependency_job_id":null,"html_url":"https://github.com/Jerakin/defold-post-process-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerakin%2Fdefold-post-process-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerakin%2Fdefold-post-process-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerakin%2Fdefold-post-process-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jerakin%2Fdefold-post-process-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jerakin","download_url":"https://codeload.github.com/Jerakin/defold-post-process-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242843439,"owners_count":20194374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blur","defold","example","postprocess"],"created_at":"2024-07-29T17:40:24.331Z","updated_at":"2025-03-10T11:32:52.626Z","avatar_url":"https://github.com/Jerakin.png","language":"Lua","readme":"# Post Process Blur Example\n\nExample of how to add a blur to everything.\n\nOnly the `post_process.*` files are relevant for our example\n\n## Step by step - Render script\n\nCopy the builtin `.renderscript` and `.render`.\n\nTo the render scripts init function add `self.effects_pred = render.predicate({\"post_effects\"})` and \n\n```lua\n    local target_params = {\n        [render.BUFFER_COLOR_BIT] = {\n            format = render.FORMAT_RGBA,\n            width = render.get_window_width(),\n            height = render.get_window_height()\n        }\n    }\n    self.target = render.render_target(\"effects\", target_params)\n```\n\nThe `predicate` dictates what is being rendered, we will later use this name to setup the material. The `render_target` is what we will render too instead of the frame buffer.\n\nNow rename the `function update(self)` to `local function do_world(self, window_width, window_height)`. Create a new function called `local function do_gui(self, window_width, window_height)` remove this bit from your `do_world` function and put it into your `do_gui`\n\n```lua\n    local view_gui = vmath.matrix4()\n    local proj_gui = vmath.matrix4_orthographic(0, window_width, 0, window_height, -1, 1)\n    local frustum_gui = proj_gui * view_gui\n\n    render.set_view(view_gui)\n    render.set_projection(proj_gui)\n\n    render.enable_state(render.STATE_STENCIL_TEST)\n    render.draw(self.gui_pred, {frustum = frustum_gui})\n    render.draw(self.text_pred, {frustum = frustum_gui})\n    render.disable_state(render.STATE_STENCIL_TEST)\n\n```\n\nNow create a new update function `function update(self)` in there add \n\n```lua\nfunction update(self)\n    local window_width = render.get_window_width()\n    local window_height = render.get_window_height()\n    if window_width == 0 or window_height == 0 then\n        return\n    end\n    render.set_render_target(self.target)\n    do_world(self, window_width, window_height)\n    render.disable_render_target(self.target)\n    \n    render.enable_texture(0, self.target, render.BUFFER_COLOR_BIT)\n    render.draw(self.effects_pred, {frustum = frustum}) \n    render.disable_texture(0, self.target)\n    \n    do_gui(self, window_width, window_height)\nend\n```\n\n\n## Step by step - Model\nCreate a new material and use the builtin `model.fp` and `model.vp` for it. Under Samplers add `effects` and under Tags add `post_effects`\n\n\nIn your main scene create a quad that is as big as your render view, center it and apply our material to it.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJerakin%2Fdefold-post-process-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJerakin%2Fdefold-post-process-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJerakin%2Fdefold-post-process-example/lists"}