I am currently learning about shaders and rendering stuff, I thought it would be good to know how to render to a target that is a different size than the actual screen. But I am stuck so here I am.
I have a render target that is rendered onto a quad as a texture, the quad is rendered infront of a sprite that look like the picture bellow. It is rendered with the current parameters. Set in the init()
local color_params = { format = render.FORMAT_RGBA,
width = render.get_window_width(),
height = render.get_window_height() }
local target_params = {[render.BUFFER_COLOR_BIT] = color_params }
self.target = render.render_target("effects", target_params)
with the viewport, view and projection in update()
render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
render.set_view(vmath.matrix4())
render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
This gives me the following result. It looks as expected.
I then change the parameters of the color parameters in init()
local color_params = { format = render.FORMAT_RGBA,
width = render.get_window_width() * 0.5,
height = render.get_window_height() * 0.5 }
This should give me a render target of half the size, is this a correct assumption? It now looks like this.
I assume that this is because the render tagets size now only fills the bottom left quarter of the projection?
Halving the viewport will not work because that controls which parts of the screen is rendered, halving it makes it look like this
// With the halved color_params above
render.set_viewport(0, 0, render.get_window_width() * 0.5, render.get_window_height() * 0.5)
Changing the projection only changes how much of the quad is seen by the camera.
It almost feels like the UVs (does a render target have UVs? It should right?) of the render target is also halved, but I want to keep it at the screen size. Is this thinking correct? Any points on how to do this would be awesome.