It looks like you're new here. If you want to get involved, click one of these buttons!
anyone know if there’s a way to cull a Mesh Rect?
https://codea.io/reference/Shaders.html#mesh.addRect
basically i’m rewriting my bitmap fonts to use rects instead of individual meshes. the problem with this approach is if i have a long swath of texts, each rect will be looped for each character even if it’s off screen. at least that is what it appears like to me.
Comments
Other than that, unless you modify the text mesh every frame to clip manually I don't think there's any other way.
@skar The mesh rect API just adds 2 triangles to the mesh to form a rect. So there's no culling of individual rects when they are off screen. @Steppers is right that the GPU will cull offscreen geometry for you, but will still incur some kind of performance cost (memory bandwidth and vertex processing stage).
We have similar issues to contend with when it comes to rendering text in the Codea editor itself. A few things you could do are:
So if you have 500 lines of text in a single textbox, you would have 10 meshes, of which only a few would be rendered each frame. And when you modify some text you only need to update one chunk at a time and perhaps update the overall offset of the other chunks to line everything up
This is only really needed if you have huge amounts of text and you may still get performance issues when you have 100k lines of text or something like that