Lyberta {l Wrote}:OK, this is more of a technical thread. I'm working on the 2D engine and pixel art is not something I want for my games. Realistic HD textures also don't make much sense in 2D. So this basically leaves vector graphics. So, what are the technical details of such implementation?
Well, out of the all vector graphics formats the SVG seems to be the only popular one. And it comes with its own animations. Has anyone worked with this? You can make SVG files in text editor or in Inkscape. So, does anyone use SVG for graphics in their games? What about models? It looks like Godot has skeletal animation even in 2D. What format to use? What about glTF for 2D?
Julius {l Wrote}:I think there is interesting stuff happening with vertex shaded but high resolution 3d art in the mobile VR space.
fluffrabbit {l Wrote}:but Half-Life set developers straight for a couple decades.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:One thing I do know is that SVG is too slow for realtime display because it antialiases each layer individually rather than the composite graphic.
Surely we can write our own rasterizing code.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:SDL_image loads non-animated SVGs as bitmaps, and that is probably the easiest way to use 2D vector graphics if you are using C/C++.
But that means camera zoom would reveal pixels unless I rasterize each frame.
Lyberta {l Wrote}:I plan to use the proposed 2D graphics TS which uses Cairo on Linux.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:They played around with voxels for a while in the Build engine, but Half-Life set developers straight for a couple decades.
Well, I would say Far Cry proved that you could do much better than HL. I remember around 2008 I was mapping for Team Fortress 2 and "enjoying" waiting ~40 minutes for my map to compile and then I've seen the video of Crysis map editor that did everything and much better in real time. That was a big existential crisis (oh wow, I didn't plan that pun) for me.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:If your engine only supports OBJ models, Blender can export animations as a series of them for use in a similar way to frames of sprites. If you're using a 3D format, textures are a must. The future is PBR and POM and volumetric raytracing where textures might even be considered outdated, but right now you can use low-res 32px or 64px textures that look very basic and oldschool.
I don't have any model support right now and I want smooth animations so rendering them as preset frames doesn't suit my goals.
Lyberta {l Wrote}:Surely we can write our own rasterizing code.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Very ambitious. SVG is built on top of XML, has a separate language to control its animations, and supports paths and other shapes which aren't a 1:1 match with OpenGL triangles. That's layers of complexity, while writing a 3D model loader is doable by a single person within a week (animations notwithstanding). There might be code out there to triangulate SVG, so that would be a start.
That library I linked has SVG demo. It looks like it uses RapidXML and SVG++ for most of the work. I know, not quite the DIY way but seems to be possible.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Textures with crazy high resolutions and trilinear filtering for smooth scaling is doable on phones, web browsers, you name it. GLES3 guarantees 4K textures per the standard.
But why would I have a huge textures instead of having a bit of XML and drawing it instead?
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Blasphemy. If that becomes standard C++, the message is that there is one specific way that 2D graphics should be rendered
Not really. It means that there will be a default way to render 2D and 90% of people wouldn't need to hunt down some 3rd party library. There is also an audio proposal too.
Lyberta {l Wrote}:drummyfish {l Wrote}:A series of OBJ frames does produce smooth animation, you interpolate between the frames, so they're more like keyframes.
Does it store the curve parameters for interpolation?
Lyberta {l Wrote}:dulsi {l Wrote}:Does vector format really solve the problem? While you it can still stay sharp when you are close to it, I'm not sure you are going to get something that looks complex like tree bark without a very complex graphic. (I'm not an artist and have not played much with svg so I could be uninformed.
Well, one very important problem is not being able to play a lot of games on high PPI monitor because they've chosen raster graphics and only provided default resolution textures. For example, Hedgewars, I have to mostly blindly select weapons based on memory and when I zoom in so I can see the map, I see pixelated mess.
Lyberta {l Wrote}:Does it store the curve parameters for interpolation?
Lyberta {l Wrote}:Well, I want to save on hitboxes so I wanted collision detection to use actual models and I plan on continuous collision detection which require to define everything using math formulas. And considering that consumer monitors right now go up to 240 Hz. Storing that much of animation seems impractical.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:It's a tradeoff between graphics memory and performance. If the library rasterizes by doing a memset every line, layer by layer, it's not going to be as fast as an OpenGL texture lookup at every pixel. If it turns everything into an optimized intermediate format like a triangle mesh, it could be faster than the texture route, but textures are still fast. GPUs are built around textures; that's their main advantage over software rendering.
So again, depends on the library. And considering how important 2d rendering is nowadays, I'm pretty sure people have thought about it. Like on Windows there are Direct2D and Direct3D. I'm pretty sure they both use GPU efficiently.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:90% of people should just be using PyGame or something anyways.
In my experience, language with dynamic typing are impossible to program with. I have to write Python scripts for my C++ libraries because there is no other sane package manager for C++ now than Conan and it forces Python. Pythons sucks extremely. I also messed with Lua trying to write actual code. It's insane. 99% of the code is just checking that your arguments are valid.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:I seriously doubt this is going to improve software quality.
It is because it is using idiomatic C++ unlike most other libraries that are basically C.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Rather, it's going to turn C++ into the new Java and scare more conservative programmers back to C, losing a lot of C++'s core advantages like being able to copy large chunks of data as function parameters.
Eh? How is giving developer better tools would scare them? It doesn't add garbage collection, it doesn't add virtual machine and all that crap. It keeps C++ C++.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:No, you interpolate between the frames to fudge a higher framerate from whatever the exported framerate was. vertC = lerp( vertA, vertB, f ) (Or you can use a different interpolation method, but that data typically isn't in the OBJ files; OBJ isn't an animation format.) It's called shapekey animation, but Wikipedia uses some nonsense Quake term for it. It's pretty ubiquitous, you just live with whatever precision you get.
Well, I'd rather use something with proper animation baked in.
drummyfish {l Wrote}:Just to make it clear you don't have to save 240 OBJ frames per second.
drummyfish {l Wrote}:I have yet to find a structurally clean way to interpolate meshes in the vertex shader, so you would be interpolating the vertices in C/C++ and updating the mesh at 60 FPS
drummyfish {l Wrote}:drummyfish {l Wrote}:I have yet to find a structurally clean way to interpolate meshes in the vertex shader, so you would be interpolating the vertices in C/C++ and updating the mesh at 60 FPS
Definitely should be done in vertex shader. It's been a long time since I've been involved with OpenGL, but can't you just update the vertex buffer e.g. at each keyframe? Send 2 position coordinates to each vertex and then only update the interpolation parameter. I know I've done it this way some time in the past. Maybe that's what you call not structurally clean?
Lyberta {l Wrote}:fluffrabbit {l Wrote}:But we're talking about 2D vector graphics. That's mainly an Adobe thing. Games by and large don't use it, so SDL, Direct2D, etc. efficiently render textures. (Well, SDL isn't especially efficient at that, but it's still fast enough.)
Well I'm going to use them. And my primitives are shapes, whether consisting of line segments are curves, and filling them with something. That's not how 3d usually works. I've heard that NURBS is the implementation of true curves in 3D but only seen it in modelling software.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:The library probably works, and SFML too is a fairly complete system for C++ with similar functionality. The problem is in trying to make these things part of the STL. I don't think that would be a good idea.
As someone who touched it, it doesn't look idiomatic at all. It has constructors that do nothing. I'm also pretty sure it uses error codes instead of exceptions.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:It's an additional tool, not a better tool. It reminds me of the failure of Java3D and other various libraries that came packed with Java but that people didn't end up using.
But a lot of people use Swing and it has much more features than a 2D library.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Even if C++ stays the same language, this API would lower the barrier to entry for low-end software and GUI apps
That's the point.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:I like C++ for what its syntax can do, not for what the STL can do outside of strings and vectors. I use third-party libraries for more advanced stuff because they're better. But you communists seem to like handing control to authority figures rather than solving problems on your own. And yes, I will throw away C++ and turn to drink if this makes it into the standard.
In my experience there are almost no 3rd party libraries with package manager support. Also, did you know that ISO is run by volunteers? I'm trying to participate and put some of my code into the standard. What, now I'm communist and totalitarian dictator?
Lyberta {l Wrote}:fluffrabbit {l Wrote}:but as someone who has been doing OpenGL programming for a few years I distrust a thing for realtime games that I have experienced severe slowness with in editing software and which doesn't match my knowledge of OpenGL's way of rendering.
Well, apparently OpenGL is dead and Vulkan is all the rage now. I mean OpenGL is just one of the possible abstraction layers of how hardware actually works. And from what I understand is it was designed for single threaded rendering and CPUs. If I ever get to 3D, I will most likely jump straight to Vulkan.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:So your solution is to install the libs on every computer in the world?
My solution is to expose what is already installed. Windows and macOS have native graphics APIs baked into them. Linux desktops have either X or Wayland. It's already there, just not exposed in a good way.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Come on. Software changes over time, and old crud should get thrown out, ideally being replaced by unrelated third-party software written by people with a head on their shoulders. The C++ standards committee is a mess, just like Mozilla and Russia. Better to bring your own libraries, get them from the source, and don't use too many of them.
ISO standardized interface and not the implementation. 2D graphics and audio have been on computers for several decades and all share common traits. It's the job of ISO to expose those traits.
Lyberta {l Wrote}:fluffrabbit {l Wrote}:Congrats on having software you feel is worthy of the standard. That doesn't make you a dictator. You're simply participating in a collective dictatorship.
For example, C++ doesn't have byte-based IO, so I wrote a serialization library to fix this. Now that the language itself has evolved so I could remove most of the non-portable bits I felt that it is a good time to propose it for standardization. The thing is, standard library gets a privilege of knowing the platform. All other code stays in much less privileged position because a lot of stuff is implementation defined. As soon as you assume specific behavior, your code becomes non-portable.
Users browsing this forum: No registered users and 1 guest