Jump to content

Vector Image Support


Josh

2,716 views

 Share

Building on the Asset Loader class I talked about in my previous blog post, I have added a loader to import textures from SVG files. In 2D graphics there are two types of image files. Rasterized images are made up of a grid of pixels. Vector images, on the other hand, are made up of shapes like Bezier curves. One example of vector graphics you are probably familiar with are the fonts used on your computer.

SVG files are a vector image format that can be created in Adobe Illustrator and other programs:

svg1.png.6f6d1e36a67eac748e0fa874760cc591.png

Because SVG images are resolution-independent, when you zoom in on these images they only become more detailed:

Image2.thumb.png.6753978f5fad81b6db4e2f7fe82b50ae.png

This makes SVG images perfect for GUI elements. The Leadwerks GUI can be rendered at any resolution, to support 4K, 8K, or other displays. This is also great for in-game VR GUIs because you can scale the image to any resolution.

SVG images can be loaded as textures to be drawn on the screen, and in the future will be able to be loaded as GUI images. You can specify a DPI to rasterize the image to, with a default setting of 96 dots per inch.

svg.thumb.jpg.a22a23a09d363c920d22aebc16c940a8.jpg

  • Like 4
  • Upvote 1
 Share

5 Comments


Recommended Comments

22 minutes ago, SpiderPig said:

Very nice.  Does this mean mip-maps are not needed for SVG textures on a model?

You would probably not use these for textures on a model. Maybe you would use them for signs or some decals or something like that.

This was primarily done so that we can use raster images for the GUI and have pixel-perfect icons at any DPI, whether it is an 8K monitor, a GUI in VR, or some other scale. Otherwise we would have to store a bunch of differently sized raster images for preset resolutions.

When SVGs are loaded they are rasterized, that is, converted to raster images. However, this can be done at any resolution. Mipmaps are for when the texture has more texels than the screen has pixels, like if the object is faraway. Mipmaps would still be used because it prevents far-away objects from looking grainy.

  • Like 1
Link to comment

Yeah makes sense.  The new asset loader is for Turbo, yes?  When do you think Turbo will be at a stage where we can merge Leadwerks 4 projects over to it without having to worry about missing features?

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...