• Welcome to Dark Bit Factory & Gravity.
 

2d shadow mapping

Started by ninogenio, April 28, 2013

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ninogenio

hey everyone had a boring sunday so far, was playing lots of thomas was alone on my vita so decided to give the 2d shadow mapping a go..

let me know what you guys think if i have it close to being correct. as i had no clue how this is done just went with what i thought. please do not look too hard at the code its like spagheti i just blurted it all down i know it can run 100000000% quicker too.

exe included.

Challenge Trophies Won:

hellfire

#1
Hi Nino,

looks nice!
If I wanted to create such an effect, I'd probably start with a zoom-blur (you know, this kind of thing).
It just works the other way round: instead of brightening things up, you darken it once you hit a shadow-casting pixel.

Quotehad a boring sunday, exe included.
I totally dig that!  ;D
Challenge Trophies Won:

ninogenio

cheers hellfire!.

i see what you mean about the shadows starting light then drifting dark, should be the other way round  :).
im just trying to think of how too achive it using geometry, maybe interpolate the alpha values along gtriangles starting dark then blending off into the light source. that should give a sort of soft shadow look which would be cool.
Challenge Trophies Won:

ninogenio

#3
Something like this mate.

a couple of the gtriangles go slightly off i think i know why ill try and fix in a little while. its turning out a neat little experiment.
Challenge Trophies Won:

ninogenio

ignore that last one i was trying too be a bit too clever and it didnt work. ive got it too a point im relativly happy with time too clean it up and try some diffrent things with it.
Challenge Trophies Won:

Raizor

That looks pretty damn cool ninogenio, nice work :) and K++ for sharing the source!
raizor

Challenge Trophies Won:


Kirl

Nicely done, looks great!  :cheers:

I had a few goes at 2d shadow casting including one potentionally super clever trick which failed spectacularly (I got lots of those! ;)).
www.kirl.nl
Challenge Trophies Won:

ninogenio

thanks very much guys  :)

@kirl its quite simple using geometry, im just projecting a ray from the centre of the light source to the nearest surface of the object for then based on which area that lies i project two more rays from the centre of the light through two opposit edges of the square right too the edge of the screen. then fill all that space with triangles.

im curious as too what you tried. i also tried an upscale and blur but couldnt get it too look right, and also done it purely with rays ( very easy and effective but really really slow ).
Challenge Trophies Won:

Kirl

Quote from: ninogenio on May 02, 2013
im curious as too what you tried. i also tried an upscale and blur but couldnt get it too look right, and also done it purely with rays ( very easy and effective but really really slow ).
I tried upscaling and bluring... which super clever individuals like yourself will have thought of. :skint:

It seemed promising at first, but when the shapes got too big or too irregular (with gaps for example) things would go all kinds of weird. In all it wasn't good enough for a free form shadow caster.

My best attempts were non free form point collections, I never quite fixed 2d shadows to my satisfaction.
Yours looks really good!
www.kirl.nl
Challenge Trophies Won:

ninogenio

yeah pretty much the same problems as i was having, i kind of want this too be a collection of primitives, point shadow, line shadow, rectangle shadow, and circle. so then i can mask almost any shape image i need.

but youve definitly given me some food for thought and some things too try out cheers kirl!
Challenge Trophies Won: