What's the correct way to render both sprites and 2D meshes in a flat 2D space?

(Matthew Maclean) #1

I did the pong tutorial and that worked quite well, but I’d also like to draw some basic 2d shapes. So I make a mesh and a texture and, using that texture, a material, and then add these to an entity (I think that these are correct, but of course please let me know if there’s something wrong with them).

(I can only add 2 links to this post, so here are my methods for creating the mesh, texture, and material, and for creating the entity that i want to draw, the names should be self-explanatory).

RenderFlat2D seems like it should do what I want (that is, Render 2D things on a Flat plane), but using the rendering setup from the pong tutorial or the 2D starter does not display the red square on my screen like I would like it to. I think my issue is the render plugin, but I don’t know which to use. I don’t want a lighting system or anything 3D (and I’d also like to keep being able to render sprites easily), but I can’t find the rendering plugin/system to use. The SpriteRenderdocumentation mentions a RenderFlat that might render meshes, but I can’t find anything by that name in the API docs.

Thanks.

1 Like
(Jaynus) #2

With a mesh and a texture, what your actually looking to do is use RenderPBR (which renders meshes) with an orthographic camera (top-down 2D camera projection).

1 Like
(Matthew Maclean) #3

Thanks, jaynus. By adding a RenderPbr3D::default() to my rendering plugins, I was able to get the program to spit out some new errors (which is progress!). I “fixed” these errors by adding Normal and Tangent vertices to my mesh (now make_mesh looks like this), but I’m still not seeing anything when I run my program. You mentioned a top-down orthographic camera, but the way I see to make an orthographic camera (Camera::standard_2d) doesn’t let me set the direction the camera faces, is it already top-down?

The bottom line is I’m still not seeing anything, so any pointers would be appreciated.