[SOLVED] Render post-process, model lighting by passing uniforms to shaders also predetermined movement for models, camera and such

Hi,

I have some questions.
#1st Question - Render post-process
I’m familiar with GLSL but I’m wondering how to use materials with render objects? Lets say I want to apply anti-alias to my final rendered scene, how do I apply it? I have my anti-alias GLSL code ready but how do I get the render objects result as a texture to my fragment shader so I can modify the scene to have anti-alias?
#2nd Question - Passing scene lighting information to model material
What is the correct way to pass scenes lighting information to a models material?
#3rd Question - Can you easily add rubber banded movement to models, lights and camera in Defold?
I would like to predetermine the path camera, lights and models should move in. What would be the most easiest way to achieve this in Defold?

Thank You.

  1. Check out http://www.defold.com/doc/materials

  2. The light component is very old and should not be used. Don’t know if it works at all. Maybe you could pass light info through a Lua table that you generate externally?

  3. There is no path object so you will have to find an alternate way of doing it. Maybe a bezier function that uses the positions of game objects (hard to edit, though)? Otherwise you need to import the data into a Lua structure so you can use it.

1 Like

To do post-processing you can use render targets. Create a new target with:

local color_params = { format = render.FORMAT_RGBA,
                   width = render.get_window_width(),
                   height = render.get_window_height(),
                   min_filter = render.FILTER_LINEAR,
                   mag_filter = render.FILTER_LINEAR,
                   u_wrap = render.WRAP_CLAMP,
                   v_wrap = render.WRAP_CLAMP }
var my_target = render.render_target("ungraded", {[render.BUFFER_COLOR_BIT] = color_params })

To render to a target use:

render.enable_render_target(my_target)

And when you want to use the target as a texture source:

render.enable_texture(0, my_target, render.BUFFER_COLOR_BIT)
3 Likes

This clears up a lot. Thank You!

1 Like