0
\$\begingroup\$

I'm trying to write a shader with "block/tile-wise lighting" for sprites (Coloring entire objects/tiles with the same light & brightness).

I've started with modifying the /Sprites/Diffuse shader.
The base shader yields the following result when used onto a tilemap with a point light in front of it: enter image description here

But what I want should look something like this:

enter image description here

(I made this in Paint, so sorry for the bad quality)
If you want/need another example, here is a screenshot from the game Terraria, which this idea is based upon:

Screenshot of Terraria; from Wikipedia

My idea would have been to simply access the lighting data of the center of a tile and use it for all pixels of the tile.

I'm relatively new to writing shaders, so I'm not even really sure if my idea is even possible (it probably is, but I lack the understanding to actually write the shader).
My main problem has been that I'm unable to access the lighting data of other pixels within the Surface Shader (which I based on the default Lambertian Surface Shader).
How can I do so or should I choose a completely different approach?

Every help is appreciated! Thank you in advance!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.