-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store piece sprites as vector graphics #69
Comments
This would be great, and a huge performance boost!! As long as we can convert the vector graphics back into textures on startup! |
All piece's have now been converted to an SVG! Next we can take steps towards using those svgs and re-forming the spritesheet on the client-side with them! See discussion here |
I imagine we would group all the classical pieces into one http request (as svgs are just text afterall, there has to be some way to split them into individual svgs eith javascript afterward), and other fairy pieces may or may not be in groups! Atleast, a pair of a black and white piece should atleast be merged into one request. |
We could combine them in one big JSON object or something. |
We don't even need to combine them all. If 95% of games are classical, we can just merge all the classical piece's svgs into one request, and only send the other fairy pieces when needed |
All pieces have already been converted into SVG's and been compressed. All we need to do from here is:
|
I'm going to start on this. I'm writing an outline of what I need to do:
|
The classical piece svgs take up just 9KB |
Why do we have to convert it into a PNG spritesheet? Isn't one of the main benefits of using SVGs (Scalable Vector Graphics) the scalability? |
WebGL can't directly render vector graphics. BUT, we can create a texture of any resolution out of an svg. I've programmed the spritesheet generator to aim to make the spritesheet large enough so that each image is atleast 512 pixels. That is more than enough for crisp clarity at all zoom levels. The spritesheet size won't exceed the maximum size supported by your device, but that number is VERY big for most devices. |
The current spritesheet size has all the pieces at a width of 256 pixels, and there's a little bit of fuzziness when zooming in. But doubling this looks great! |
#374 Added the majority of these features. All that remains now is to add an error message to the loading animation if by chance the page fails to load the svgs for a loaded game. |
Okay an error message now shows if one of the fetch requests fail during spritesheet generation. However there isn't a retry button or automatic-refreshal, it just asks you to refresh. If you try to leave the game while the error message is up it totally breaks it. |
Lichess stores all its piece sprites as vector graphics (see here, for example) and each piece is less than 1KB in file size. In contrast, our spritesheet is a png file and takes up 1MB in total.
We should also store piece sprites in svg format.
The text was updated successfully, but these errors were encountered: