Swap Help Needed Please???

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BigDC

Here is what I am wanting to do, the basic idea is to create a colormap and a 2D sprite and perform a per-province palette-swap in the sprite’s fragment shader based on the province’s RGB value.

Conceptually, you’d keep two textures, a colormap texture, and a lookup texture. The colormap could be whatever size you want, but the lookup texture has to be of size 4096*4096.

Think about this in the use of Games such as Risk, Civ V, Heroes of Iron and many others. where irregular shapes gets selected and their color changed.

Could you please show me some sample code to do this, please? Thanks!

You’re putting the cart before the horse my dude. If you got this shader working, how do you handle input events so your player can interact with your map? How do you translate get_global_mouse_position() to a particular region on the map?

Mathematically, there is no is_inside_polygon(position) function for irregular shapes unless you define the collision polygons yourself at which point you can just use that data to do the coloring for you. That’s why I recommended you go with a hex-based map like Civ6.

timothybrentwood | 2021-05-10 13:38

Not really. Everything else I can figure out. I just need help with above, please?

BigDC | 2021-05-11 04:30