SFML community forums

Help => Graphics => Topic started by: wilbefast on March 12, 2011, 01:29:36 pm

Title: Blending shadows correctly
Post by: wilbefast 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:
(http://i54.tinypic.com/4rcg2q.png)

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
Title: Blending shadows correctly
Post by: Laurent 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.
Title: Blending shadows correctly
Post by: wilbefast 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:

(http://www.saltgames.com/wp-content/uploads/2009/10/unannotated-light-and-single-wall.png) (http://forums.tigsource.com/index.php?topic=8803.0)
Title: Blending shadows correctly
Post by: Laurent on March 12, 2011, 07:31:07 pm
Nop, sorry. I don't think you can do that in 1.6.
Title: Blending shadows correctly
Post by: wilbefast 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...
Title: Blending shadows correctly
Post by: WitchD0ctor 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
Title: Blending shadows correctly
Post by: Groogy 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.
Title: Blending shadows correctly
Post by: heishe 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?
Title: Blending shadows correctly
Post by: Laurent on March 14, 2011, 09:36:33 am
Quote from: "Laurent"
And it's for SFML 2.

;)
Title: Blending shadows correctly
Post by: heishe 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!