Sending a message to render script


We’re supposed to be able to use something like:"@render:", “use_fixed_fit_projection”, { near = -1, far = 1 })

so we don’t need to copy and change the built-in render script, but that doesn’t seem to be working if I change the near/far values.

In the default render script, update function, there’s a line:

render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))

which should probably be?

render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), self.near, self.far))

I am using editor 1.2.163, deleted the cache and build folders to make sure I am getting the updated built-ins.

In the meantime, I just copy the default render script with changes above, and it works ok now.



That line is for when rendering the gui, which typically doesn’t care about the z-value of gui components. Does this cause a problem in your project?

1 Like


I am doing something like this:

From the render manuals, I thought I can simply add this instead: ("@render:", “use_fixed_fit_projection”, {near=-50, far=50})

But the new near/far values being passed are not really being used in the update function of the built-in render script (still uses -1,1, so it ignores the passed values). So the solution was still to copy and create your own render script.

I just posted it here in case someone else encounters the same issue again in the future. I understand more advanced projects will likely be using their own render scripts anyway. But for those new to Defold and render scripts (like me), it took me some time to figure out what’s wrong as I was expecting that 1-line to work :slight_smile: