after many attempts i’ve gotten a basic version of 2D lights to work in codea -
the demo project is attached
a few areas i’d like to improve on are
the x and y positions is kinda weird, I’ll have to recalculate it to fit into whatever resolution the active device is so 0,0 is bottom left and 1,1 is top right
is there a better way to use multiple meshes without each of them needing their own duplicate shader? maybe i need to pass the textures and normal maps as arrays
try to get a spotlight effect (solid light color, i think this one is easy to do just remove the falloff)
test to see how to get a flashlight effect (with the light scattering and lines one would see as they focus and unfocus)
@RonJeffries In the old days this is where @Ignatz would chime in with a link to his tutorial book about shaders in Codea.
( Miss ya Iggy ??)
Seeing as he’s pursuing other things now (not a euphemism for death, he’s just actually more interested in other things, so I hear) I’ll do the honors:
@UberGoober i believe you’re seeing an optical illusion, if you add a cutoff value so that the light only applies to part of the image in a circle, you will see the image doesn’t grow, just the way the light scatters makes it look like it’s moving
Maybe. Try layering the attached images on top of each other in an art program and then toggling between the layers. Some amount of increased contour definition could certainly be contributing to the effect, but there seem to be several places where the change in the apparent borders of the rocks looks more sizable than that. I could be wrong though for sure.
the light scattering depends on the normal map and it is not perfect, here i highlighted the bottom example showing it has the light dropping out sooner than the actual shape of the stone
the rocks normal maps is probably the lowest quality but it does have a nice phong effect like it’s wet stone so i thought it would be ok to keep it