logoalt Hacker News

diathtoday at 4:00 PM2 repliesview on HN

> A picking texture is a very simple idea. As the name says, it’s used to handle picking in the game, when you click somewhere on the screen (e.g. to select an unit), I use this texture to know what you clicked on. Instead of colors, every object instance writes their EntityID to this texture. Then, when you click the mouse, you check what id is in the pixel under the mouse position.

Unrelated, but why? Querying a point in a basic quad tree takes microseconds, is there any benefit to overengineering a solved problem this way? What do you gain from this?


Replies

pacificat0rtoday at 4:05 PM

Well, it's significantly easier to implement than a octree. Game is actually 3D under the hood, projected at a careful angle to look isometric 2D.

The reason the game is 3D has to do with partially visible things being way easier than with isometric textures layered in the right order.

Also, now that i just grab a pixel back from the GPU, it's no overhead at all (to construct or get the data for it).

rcxdudetoday at 4:05 PM

It aligns with what appears on the screen accurately and without needing any extra work to make sure there's a representation in a tree that's pixel-accurate. It's also pretty low overhead with the way modern GPU rendering works.

show 1 reply