Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Blending shadows correctly  (Read 3861 times)

0 Members and 1 Guest are viewing this topic.

wilbefast

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • http://wilbefast.com
Blending shadows correctly
« on: March 12, 2011, 01:29:36 pm »
I'm having a bit of trouble correctly blending shadows - I don't want the area to be darkers when there are multiple shadows lying on top of eachother:


Is there a way to iteratively build a sort of layer and then composite it on top of the render target? At the moment I'm exporting a list of vertices from the pathing matrix and projecting each point of each one to create a 4 point polygon.

William

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Blending shadows correctly
« Reply #1 on: March 12, 2011, 01:35:50 pm »
There's a source code on the wiki for a complete light manager:
http://www.sfml-dev.org/wiki/fr/sources/lightmanager

The page is in french but you should be able to use the code.

And it's for SFML 2.
Laurent Gomila - SFML developer

wilbefast

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • http://wilbefast.com
Blending shadows correctly
« Reply #2 on: March 12, 2011, 03:12:34 pm »
You forget that I'm fluent in French (I just occasionally get my genres wrong)  :P

Thanks for the link - still, is there no way to build an image iteratively in 1.6? Something along the lines of (pseudo-code):

Code: [Select]

pixel_buffer temp_image(view.width,view.height,colour(255,255,255));
for each vertex in view
{
   Polygon shadow(colour(0,0,0));
   shadow.add(vertice.start); //A
   shadow.add(projection(vertice.start)); //B
   shadow.add(projection(vertice.end)); //C
   shadow.add(vertice.end); //D

   temp_image.draw(shadow);
}

temp_image.set_alpha(200);
window.draw(temp_image);

I've been following this guide on tigsource:


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Blending shadows correctly
« Reply #3 on: March 12, 2011, 07:31:07 pm »
Nop, sorry. I don't think you can do that in 1.6.
Laurent Gomila - SFML developer

wilbefast

  • Newbie
  • *
  • Posts: 31
    • View Profile
    • http://wilbefast.com
Blending shadows correctly
« Reply #4 on: March 13, 2011, 10:34:12 am »
Okay then - good to know their way. Guess I'd better switch to 2.0 for my next project...

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
Blending shadows correctly
« Reply #5 on: March 13, 2011, 07:38:04 pm »
Quote from: "Laurent"
There's a source code on the wiki for a complete light manager:
http://www.sfml-dev.org/wiki/fr/sources/lightmanager

The page is in french but you should be able to use the code.

And it's for SFML 2.


what??? That is awesome, wish I knew that was there before
John Carmack can Divide by zer0.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Blending shadows correctly
« Reply #6 on: March 13, 2011, 08:48:59 pm »
And for those who don't speak/read French, there's Google Translate.

Got interested so I wanted to read it and translate worked pretty well. There were some inaccurate translations I think but you could understand the underlining message.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Blending shadows correctly
« Reply #7 on: March 14, 2011, 09:34:19 am »
That code is SFML 1.6 right? How much work would it take to convert it to 2.0, just change the way stuff is drawn?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Blending shadows correctly
« Reply #8 on: March 14, 2011, 09:36:33 am »
Quote from: "Laurent"
And it's for SFML 2.

;)
Laurent Gomila - SFML developer

heishe

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Blending shadows correctly
« Reply #9 on: March 14, 2011, 12:26:50 pm »
Ooops. Shame on me :)

Now I just need to wait for your Radeon HD fix and I can actually try it out!