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

Author Topic: Simple static 2d shadows  (Read 13503 times)

0 Members and 1 Guest are viewing this topic.

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #15 on: August 17, 2010, 02:44:11 pm »
Okay so I got everything working with the views, I was doing some bad maths that was screwing it up. However I finally managed to find something that isn't my fault (at least I don't think it is)

In the documentation you say

Quote
Clear (const Color &color=Color(0, 0, 0))
Clear the entire target with a single color.


However I made a RenderImage and just because I am a persistant bastard I decided I would put

Quote
image.Clear(sf::Color(0,0,0,0));


And to my surprise it worked... The RenderImage was invisible and the stuff I drew on it wasn't! I tried different background colors just in case I had white on white but I am pretty confident its not me. If I am right about this we will both be very happy =)

(Sorry if I didn't make sense, im excited about RenderImage's having alpha support!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Simple static 2d shadows
« Reply #16 on: August 17, 2010, 08:03:21 pm »
Of course RenderImage supports alpha ;)

I don't understand what's "wrong" with what you showed, it behaves as expected.
Laurent Gomila - SFML developer

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #17 on: August 18, 2010, 12:56:49 am »
Well the documentation says that clear only supports R G B and not A

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Simple static 2d shadows
« Reply #18 on: August 18, 2010, 06:36:56 am »
Quote from: "general sirhc"
Well the documentation says that clear only supports R G B and not A
No it doesn't.
I use the latest build of SFML2

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #19 on: August 18, 2010, 07:15:44 am »
Quote from: "OniLink10"
Quote from: "general sirhc"
Well the documentation says that clear only supports R G B and not A
No it doesn't.



Quote

Public Member Functions
    RenderImage ()
    Default constructor.
virtual    ~RenderImage ()
    Destructor.
...
...
...
void    Clear (const Color &color=Color(0, 0, 0))
    Clear the entire target with a single color.


Yes it does

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Simple static 2d shadows
« Reply #20 on: August 18, 2010, 07:32:13 am »
Quote from: "general sirhc"
Quote from: "OniLink10"
Quote from: "general sirhc"
Well the documentation says that clear only supports R G B and not A
No it doesn't.



Quote

Public Member Functions
    RenderImage ()
    Default constructor.
virtual    ~RenderImage ()
    Destructor.
...
...
...
void    Clear (const Color &color=Color(0, 0, 0))
    Clear the entire target with a single color.


Yes it does
No, that's a default value. When you make an sf::Color, a defaults to 255, so you don't have to specify it. That const Color &color=Color(0, 0, 0) just means if you don't give it a parameter, it defaults to black.
I use the latest build of SFML2

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #21 on: August 18, 2010, 07:40:30 am »
Oh I getcha, well it would be nice if it was

clear(0,0,0,255) for the default in the documentation, I was confused for a while about it

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Simple static 2d shadows
« Reply #22 on: August 18, 2010, 08:22:58 am »
Quote
Oh I getcha, well it would be nice if it was

clear(0,0,0,255) for the default in the documentation, I was confused for a while about it

I think that reading the sf::Color documentation would help you more than me always using the 4-components color constructor ;)
Laurent Gomila - SFML developer

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #23 on: August 18, 2010, 08:34:00 am »
Laurent I can't help it if you have a tendency of being right all the time.

Although I still think it would be nice if it had the 4 arguments in the documentation just so it was nice and clear for dumb dumbs =)

Btw do you plan on adding more blend modes or custom blend modes? Either would be very nice =)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Simple static 2d shadows
« Reply #24 on: August 18, 2010, 08:47:33 am »
Quote
Although I still think it would be nice if it had the 4 arguments in the documentation just so it was nice and clear for dumb dumbs =)

Ok, you win :P

Quote
Btw do you plan on adding more blend modes or custom blend modes? Either would be very nice =)

No, but we can talk about it. Which blending modes would you like to have?
Laurent Gomila - SFML developer

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #25 on: August 18, 2010, 10:41:33 am »
subtract: Because its an important on for doing shadows

There is also
add
max
one
zero

But I personally have no use for them at the moment

Why can't you add custom blend modes?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Simple static 2d shadows
« Reply #26 on: August 18, 2010, 10:48:13 am »
Quote
subtract: Because its an important on for doing shadows

Can you explain this? Usually, shadows are achieved using add + multiply (which are both available in SFML).

Quote
Why can't you add custom blend modes?

I can :)
I just want to keep it simple, I don't want people to have to deal with source/destination and all OpenGL modes.
Laurent Gomila - SFML developer

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #27 on: August 18, 2010, 11:10:29 am »
Blendmodes are not my strong point so I hope you don't mind me quoting the GM manual here.

Quote
Besides the normal mode it is possible to indicate that the new color must be added to the existing color or subtracted from the existing color. This can be used to create e.g. spot lights or shadows.


Basically with subtract black takes nothing off the color already drawn and white would take all the color. So if you draw 128,128,128 color with subtract blend mode what ever it was drawn over would be darkened by half.

Also again from the book of GM it would be much better to simply have a second command which is for advanced users.

SetBlendMode(blend mode)
SetBlendModeAdv(source blend,destination blend)
Or a different naming scheme
SetBlendModeExt(source blend,destination blend)

Either way it allows basic users to keep using the simply blend modes and advanced users to use the more advanced version... Although I think it would be for intermediate users not advanced since I probably can do this through openGL how things are now instead, couldn't I?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Simple static 2d shadows
« Reply #28 on: August 18, 2010, 12:23:18 pm »
Quote
Basically with subtract black takes nothing off the color already drawn and white would take all the color. So if you draw 128,128,128 color with subtract blend mode what ever it was drawn over would be darkened by half.

Multiply is usually better to darken things, I don't think that Subtract is necessary for shadows.

Quote
Also again from the book of GM it would be much better to simply have a second command which is for advanced users.

SetBlendMode(blend mode)
SetBlendModeAdv(source blend,destination blend)
Or a different naming scheme
SetBlendModeExt(source blend,destination blend)

I know that I can provide such an API, it's just that I don't want to :)
I never add features jst because "I can", I add them when they are really necessary.
Laurent Gomila - SFML developer

general sirhc

  • Newbie
  • *
  • Posts: 19
    • View Profile
Simple static 2d shadows
« Reply #29 on: August 18, 2010, 12:37:48 pm »
Personally I think its necessary, maybe you should do a poll of what the users think, blend modes are an important part of graphics rendering

 

anything