Light Sources
#1
Posted 29 August 2011 - 12:20 PM
I have a feeling I could use blend modes to get the effect I want, but I've never really experimented with them before and my first attempts have failed miserably.
Is there a way to do this? I basically want a circle around the lightsource to remain 'lit' when the darker rectangle is drawn.
#2
Posted 29 August 2011 - 12:56 PM
I've come across this problem before, but only ever came up with a very low-level solution, nothing fancy. Create a sprite that consists of a black background, with a transparent circle in the centre (so it looks like a black square with a hole drilled through the centre). We'll call this "hole_spr" Now, where you have a light source, have it draw hole_spr over the scene with the same alpha value as the "night" rectangle -- you can scale the image up to suit the intensity of the light.
Here's the complicated bit. You need to "stitch" the bits where hole_spr occurs together. Instead of using one big rectangle for the screen, you'll need to use little ones and patch them all over the screen without an overlap. With a single light source on the screen this is trivial. If there are multiple light sources, at the moment I can't think of a simple way of patching the pieces together without overlap.
Like you, I suspect there's a better solution (blend modes?). But I don't know what it is.
Hope this helps anyway!
#3
Posted 30 August 2011 - 04:34 AM
Hmm, the problem with that method is two-fold: 1, there will be multiple light-sources (no set number, more could appear at any time); 2, the light-sources will change position arbitrarily (at the whim of the player). 'Stitching together' would be nigh-on impossible, and certainly more trouble than it's worth, in this case.Hey.
I've come across this problem before, but only ever came up with a very low-level solution, nothing fancy. Create a sprite that consists of a black background, with a transparent circle in the centre (so it looks like a black square with a hole drilled through the centre). We'll call this "hole_spr" Now, where you have a light source, have it draw hole_spr over the scene with the same alpha value as the "night" rectangle -- you can scale the image up to suit the intensity of the light.
Here's the complicated bit. You need to "stitch" the bits where hole_spr occurs together. Instead of using one big rectangle for the screen, you'll need to use little ones and patch them all over the screen without an overlap. With a single light source on the screen this is trivial. If there are multiple light sources, at the moment I can't think of a simple way of patching the pieces together without overlap.
Like you, I suspect there's a better solution (blend modes?). But I don't know what it is.
Hope this helps anyway!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











