Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: ninogenio on April 28, 2013

Title: 2d shadow mapping
Post by: ninogenio on April 28, 2013
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.

Title: Re: 2d shadow mapping
Post by: hellfire on April 28, 2013
Hi Nino,

looks nice!
If I wanted to create such an effect, I'd probably start with a zoom-blur (you know, this (http://thebest3d.com/pdpro/tutorials/funwithparticles/Clipboard50.jpg) 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.

Quote
had a boring sunday, exe included.
I totally dig that!  ;D
Title: Re: 2d shadow mapping
Post by: ninogenio on April 29, 2013
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.
Title: Re: 2d shadow mapping
Post by: ninogenio on April 29, 2013
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.
Title: Re: 2d shadow mapping
Post by: ninogenio on April 29, 2013
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.
Title: Re: 2d shadow mapping
Post by: Raizor on April 29, 2013
That looks pretty damn cool ninogenio, nice work :) and K++ for sharing the source!
Title: Re: 2d shadow mapping
Post by: Hotshot on April 29, 2013
Cool Shadow :)
Title: Re: 2d shadow mapping
Post by: Kirl on April 29, 2013
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! ;)).
Title: Re: 2d shadow mapping
Post by: ninogenio on May 02, 2013
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 ).
Title: Re: 2d shadow mapping
Post by: Kirl on May 03, 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!
Title: Re: 2d shadow mapping
Post by: ninogenio on May 05, 2013
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!