Using ALPHAMODE to have both shadowed and illuminated areas

Previous topic - Next topic

spicypixel

Is there a way I can use ALPHAMODE - to have my existing graphics darkened on-screen and then illuminated with ALPHAMODE +. I don't want the opacity of 0 to -1 I just want darker gfx :( I could create a big sprite to fill the screen in black with a circle cut out of the middle (with alpha gradient) for viewing area but it's a lot of gfx to blit each frame. Any other ideas that won't be CPU intensive?

Ideally a darkened screen (not totally black) and then an area illuminated around the main sprite.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Kitty Hello

draw a black rectangle over it?
On a PC you could try a shader. On all devices make a temporary sprite and use SPRITE2MEM and MEM2SPRITE to darken the pixels.. maybe.

AMateus

Isn't there a way to set the object material?

This type of effects (darken, lighten, etc) is achieved by the object's material  (ambient, diffuse, specular and emissive).

Basically, materials configure how the object will reflect the lights. We can even set part of the object to glow while the other parts are dark (ex: a house by night with the windows glowing because of the inside lights?)

António

spicypixel

Quote from: Kitty Hello on 2011-Oct-25
draw a black rectangle over it?
On a PC you could try a shader. On all devices make a temporary sprite and use SPRITE2MEM and MEM2SPRITE to darken the pixels.. maybe.

The problem with drawing the black rectangle is that if I set the opacity to nearly black, will ALPHAMODE +1 give enough brightness to show my detail for the area I want illuminated or is it likely to be washed out. Guess I should try really :)

@Antonio this is for PolyVector sprites and not 3D objects bud.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

AMateus

Quote from: spicypixel on 2011-Oct-25
@Antonio this is for PolyVector sprites and not 3D objects bud.

Ups... disregard my post then =)

Slydog

Are you using POLYVECTORs?
If so, just have a dark colour and a bright colour defined.
When plotting the POLYVECTORs in the dark areas use the dark colour for the last parameter (colour), or else use your light colour (white probably).

This will give you a square (rectangle) for the hi-lighted main sprite area.
Then just plot one more small gradient alpha sprite on top of your main sprite to achieve the circular look.

[Edit]  Hmm, well maybe not as easy as that.  It doesn't account for when your main sprite is part way between tiles, so two tiles are affected.  You could have your gradient as large as 2x2 tiles (or 3x3 for the scrolling), with the bright area in the middle the size of your main sprite, and draw your bright polyvectors around your main sprite in a 2x2 grid.  Not sure if this will work now!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Wampus

I think playing with the POLYVECTOR brightness by changing colour values is your best bet, e.g. if RGB(255,255,255) is full brightness then RGB(127,127,127) is half brightness. The CPU/GPU will take a bigger hit but it might be acceptable.

If you're working with rectangular sprites then it should be possible to calculate how bright each corner of the sprite should be relative to the distance from the player character. It probably wouldn't look perfect in all situations but it would be relatively quick to calculate.

spicypixel

Im using PV's but the target device is iPad so the GPU hit is supposed to be greater. I'll endeavour to find a good solution. Thanks guys :)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Slydog

You could always just have two copies of your tiles, one dark, and one normal/bright.
The dark copy could be created at the start with CREATESCREEN and drawing the original tiles sprite, and an overlaid dark polyvector.

You still have to figure out the details of how to do the main sprite gradient.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]