M
M
maaGames2015-11-07 08:43:27
Shaders
maaGames, 2015-11-07 08:43:27

How to apply light map?

There is a medium sized tile map, let's say 1024*1024 tiles. The tiles are square, 48*48 pixels. There is an illumination map for the entire map, sized 1024*1024 pixels. Those. each tile has one pixel. Due to linear interpolation between tiles, illumination is interpolated. The viewport size is 960*540 pixels, so at least 20*11.25 tiles are visible on the screen. The viewport moves pixel by pixel in any direction (scrolling). I can't figure out how to make it so that only a piece of the light map is applied, depending on the visible tiles?
47b5bb0b2aaf43c8850b663bade009a7.jpg
I drew an example in the picture: the entire shadow map was projected onto the screen, not a small piece of it.
I could not formulate the question in such a way that Google gave out something appropriate. It needs to be implemented using a pixel shader or a sprite (on sfml, the size of the sprite is equal to the size of the rectangle inside the texture and the most obvious option did not work because of this).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question