Mapping Basics 101

Hello, new user here. Just wondering if someone could explain the mapping process clearly. I have tried everything I can do to incorporate a mapped pattern but no luck the patterns never seem to change.

Any help would be greatly appreciated.

Hi,

Does your pixel map preview look ok? Can you provide your map code, and what you are looking to do?

I think the most confusing thing (or at least the area I know I want to improve on) is that having a pixel map won’t do anything unless the pattern has a render2D or render3D function. Otherwise it just calls render() which doesn’t use the map. You can have all 3 render function variants in a single pattern, and it will use whichever is appropriate.

There are some really basic examples of a pattern that uses render2D and render3D in the mapper docs or on the mapper page, scroll down below the editor.

Regorlas made a really cool 3d mapper test pattern, and talks a bit about it here:

Howdy Ben, just getting back to some PixelBlaze hackin and for the life of me I cannot get the mapper to work. The preview on the Mapper tab looks right but it just doesn’t seem like render2D is called with the right x,y.

To start I use the Matrix example in the Mapper and change width to 30. Right away the preview looks correct, but I cannot seem to do much with the x,y coords.

Couple of tests that demonstrate odd behaviors.

export function render2D(i, x, y) {
  if(x>0) hsv(0.1,1,1)
  else hsv(1,1,1)
}

this results in the left most column being red, the rest being… mustard? sounds about right.

export function render2D(i, x, y) {
  if(x>1) hsv(0.1,1,1)
  else hsv(1,1,1)
}

but when I change to this, I would expect two red columns and beautiful mustard for the rest but instead it’s all red. Tons of variations on this result in the same, I can light the top row, or single columns but it doesnt’ actually seem to calling with the proper values.

Hi @captain_morgan,
Good to hear from you!
So the trick is that your map is normalized to world units, values between 0 and 1. I did this so for 2 reasons. The first is so you don’t have to know and divide by the width to get a positional ratio for math based patterns. The second is that it makes patterns portable to any map/layout.

Of course the downside is if you want to know a pixel in integer position you have to multiply it back out, and be weary of rounding errors.

I plan to add a raster projection setup in v3, so you can have regular integer pixels, paint images and text, then project these onto an arbitrary pixel map.

OOOOOoooohhhhh (he says as he rereads and sees it right there).
Thanks Ben, don’t know how I kept missing this. Anyhow, been fun diving back in, got a couple cools post coming up (New picture frame, MQTT controls?). Will post updates on the forums here.