Author Topic: 2d shadow mapping  (Read 6238 times)

0 Members and 1 Guest are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
2d shadow mapping
« 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.

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: 2d shadow mapping
« Reply #1 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 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
« Last Edit: April 28, 2013 by hellfire »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: 2d shadow mapping
« Reply #2 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.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: 2d shadow mapping
« Reply #3 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.
« Last Edit: April 29, 2013 by ninogenio »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: 2d shadow mapping
« Reply #4 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.
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: 2d shadow mapping
« Reply #5 on: April 29, 2013 »
That looks pretty damn cool ninogenio, nice work :) and K++ for sharing the source!
raizor

Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: 2d shadow mapping
« Reply #6 on: April 29, 2013 »
Cool Shadow :)

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: 2d shadow mapping
« Reply #7 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! ;)).
www.kirl.nl
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: 2d shadow mapping
« Reply #8 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 ).
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: 2d shadow mapping
« Reply #9 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!
www.kirl.nl
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: 2d shadow mapping
« Reply #10 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!
Challenge Trophies Won: