Hello guys. This is my first post, so if I posted in the wrong section please let me know.
Ok, so I'm making a game similar to Terraria/Starbound (but much more modest, of course). I made an algorithm to calculate the lighting that, despite the lack of optimization right now, works pretty well (at least for my taste). But this algorithm is not important and it's not what I want to talk about here. How to render this is what I came here to discuss.
To render the tiles, I was coloring them accordingly to the "light map" and it worked "ok". This is how it looked like using this method:
Then I changed the way I was doing, so now I render the tiles "full bright" and then I render "black/colored" tiles in front of them, adjusting the alpha channel to "match" the light level (each corner using an average of the surrounding lighting). But the performance of this, of course, is not that great because I doubled the number of triangles being rendered and the "smoothing calculations". Here's how it looks like using this method:
Then I made a quick test and "rendered" (by hand?) every "tile in the light map" as a single pixel on a texture to represent the "light level", then render a single quad in front of the screen with the texture (with filters) stretched. The visual results are exactly the same as the previous method. But, to my surprise, the performance was even worse.
So I was thinking if there's a better way to do it using pixel shaders or other techiniques?
I'm using DirectX9 and C++.
Any hints will be appreciated. Thank you in advance. (sorry about my english, I can't even grammar)