Skip to content
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

raster sprites #1

Open
ghost opened this issue Feb 27, 2021 · 0 comments
Open

raster sprites #1

ghost opened this issue Feb 27, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Feb 27, 2021

We should store raster sprite images in the style png in a section after the point, line, and area regions so that style rules can use sprites for background and foreground images.

One way this could be implemented is to store the image coordinates as the first section and those coordinates can be fed to texture2D(). This way you can perform two texture2D()s in the vertex shader for the given feature to load a sprite by its index, and then load the relevant pixel for the fragment shader based on other rules.

Here is an example that specifies 3 images:

[point section]
[line section]
[area section]
[image coordinate section:
  0, 0,  1,250,  0,32,  2, 26, // img0: minx=0,  miny=506, maxx=32, maxy=538
  0, 0,  2, 58,  0,32,  2,106, // img1: minx=0,  miny=570, maxx=32, maxy=618
  0,32,  1,250,  0,96,  2, 58, // img2: minx=32, miny=506, maxx=96, maxy=570
]
[image data section: // it should look something like this, graphically:
   ________________________
  |img0   |img2            |
  |32x32  |64x64           |
  |_______|                |
  |img1   |                |
  |32x48  |                |
  |       |________________|
  |_______|

]

This example uses integer pixel coordinates (in big endian), but we might also consider half floats (in whatever endian).

When a feature uses a sprite (or multiple sprites), it references the sprite by its index in the coordinate section plus a mode (repeat, center, ...). The modes may have additional parameters, such as an offset (x,y) or even rotations that are static or follow the contours of a geometry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants