Hi
I need to draw a sprite to a render target so that later on I can use it to mask the rendering of another sprite. However, in order for this to work, I need to draw the sprite to the full width and height of the render target.
The sprite’s world position can be anything, so first I need to get the vertex shader to output “local sprite coordinates” to the render target. I’m pretty sure that in the vertex shader I can just ignore the view_proj matrix and just output the position as it goes in
gl_Position = vec4(position.xyz, 1.0);
Also, in the render script I’m pretty sure I have to set an orthographic projection and the size of the viewport to the size of the sprite
render.set_view(vmath.matrix4())
render.set_projection(vmath.matrix4_orthographic(0, 32, 0, 32, -1, 1))
render.set_viewport(0, 0, 32, 32)
. . . -- create render target here of size 32x32
render.enable_render_target(self.mask_render_target)
render.draw(self.mask_pred)
render.disable_render_target(self.mask_render_target)
However, this doesn’t seem to work. Have I missed something, are my assumptions about “local sprite coordinates” wrong?