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

Author Topic: New Shader class in SFML 2 to replace PostFx  (Read 39700 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #15 on: November 06, 2009, 12:47:11 am »
Quote from: "Laurent"
Quote
And it works, but I get blank spots on the sides of the screen

Can you show a screenshot? Have you tried to disable smoothing on your image?

Quote
and there is much lag

You didn't have it before?

Quote
Can you show a screenshot? Have you tried to disable smoothing on your image?
I just disabled smoothing, and the glitch changed slightly to this:

It also does get blackness on the top and bottom of the screen once every second, and when that happens, the darker area is on the sides.
Quote
You didn't have it before?
No, I did not. I emulated a Windows program using build 1245 or so with sf::PostFX, and it ran lag-free.
I ran a native Linux program using build 1262 with sf::Shader, and I'm getting piles of lag.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #16 on: November 06, 2009, 07:27:49 am »
Quote
No, I did not. I emulated a Windows program using build 1245 or so with sf::PostFX, and it ran lag-free.
I ran a native Linux program using build 1262 with sf::Shader, and I'm getting piles of lag.

But what about native Linux program using revision 1245?

Can you upload your project so that I can test it?

I'm surprised because the internal OpenGL code related to shaders hasn't changed at all, my modifications were almost all to the public API.
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #17 on: November 07, 2009, 01:51:24 am »
I updated to SFML 1268, and the glitch with the tearing and blackness is gone, but I still have the lag.
Here's the demo with SFML 1268.
http://willhostforfood.com/access.php?fileid=93440
Use run.sh to use the local .so files.
I use the latest build of SFML2

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #18 on: November 11, 2009, 05:22:01 am »
My laptop with ATI Radeon Mobility HD3465, Catalist 9.4 (AFAIK the last version with HD3465 support) refused to compile wave.sfx. Other shaders are Ok. Investigations showed that it had stuck at the line:
Quote
vec2 texoffset = texture2D(wave, (gl_TexCoord[0].xy * offset).xy);

If I use vec2 explicit construction, everything is Ok.
Quote
vec2 texoffset = vec2(texture2D(wave, (gl_TexCoord[0].xy * offset).xy));

I'm far far away from being a glsl guru. May this behavior be caused by the sfml current shader's version incompatibility with my hardware?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #19 on: November 11, 2009, 08:29:26 am »
Ah, true. I'll fix it as soon as possible :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #20 on: November 11, 2009, 11:03:50 am »
Quote
I updated to SFML 1268, and the glitch with the tearing and blackness is gone, but I still have the lag.
Here's the demo with SFML 1268.
http://willhostforfood.com/access.php?fileid=93440
Use run.sh to use the local .so files.

I couldn't use the local .so files (my system has a problem and needs a modified version of SFML), but I tried shaders with the latest revision:
- the Shader sample runs perfectly
- I can see the lag in your application

Can you show your source code? Did you try the Shader sample?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #21 on: November 11, 2009, 10:34:11 pm »
Hello!
float edge = sqrt(hEdge.rgb * hEdge.rgb + vEdge.rgb * vEdge.rgb);
That's some good coding right there.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #22 on: November 11, 2009, 10:54:31 pm »
Quote from: "OniLink10"
float edge = sqrt(hEdge.rgb * hEdge.rgb + vEdge.rgb * vEdge.rgb);
That's some good coding right there.

?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #23 on: November 11, 2009, 11:10:30 pm »
Quote from: "Laurent"
Quote from: "OniLink10"
float edge = sqrt(hEdge.rgb * hEdge.rgb + vEdge.rgb * vEdge.rgb);
That's some good coding right there.

?
The sqrt returns a vec3, since the value sent to it is a vec3. vec3s cannot be assigned to floats.
I use the latest build of SFML2

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #24 on: November 12, 2009, 06:24:38 am »
Quote from: "Laurent"
Quote
I updated to SFML 1268, and the glitch with the tearing and blackness is gone, but I still have the lag.
Here's the demo with SFML 1268.
http://willhostforfood.com/access.php?fileid=93440
Use run.sh to use the local .so files.

I couldn't use the local .so files (my system has a problem and needs a modified version of SFML), but I tried shaders with the latest revision:
- the Shader sample runs perfectly
- I can see the lag in your application

Can you show your source code? Did you try the Shader sample?
Here's our repository: http://mke.svn.sourceforge.net/viewvc/mke/
I tried to Shader sample, and it works fine, so I dunno what's going on.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #25 on: November 12, 2009, 08:45:27 am »
Quote
The sqrt returns a vec3, since the value sent to it is a vec3. vec3s cannot be assigned to floats.

Ah, true (my driver accepts so many errors...).
I fixed the code, thanks.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #26 on: November 12, 2009, 08:27:36 pm »
Quote
Here's our repository: http://mke.svn.sourceforge.net/viewvc/mke/
I tried to Shader sample, and it works fine, so I dunno what's going on.

It seems like clock() has a very low resolution on Linux. Using a sf::Clock solves the problem.
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #27 on: November 13, 2009, 01:26:35 am »
Quote from: "Laurent"
Quote
Here's our repository: http://mke.svn.sourceforge.net/viewvc/mke/
I tried to Shader sample, and it works fine, so I dunno what's going on.

It seems like clock() has a very low resolution on Linux. Using a sf::Clock solves the problem.
Alright then. Thanks for the help! I switched to sf::Clock and it works perfect!

On the shader sample, global fisheye Y coordinates are flipped for me. It doesn't do this with background, and I can't tell on flower.
I use the latest build of SFML2

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
dukghasfgdsg Multiple Shader Fail
« Reply #28 on: November 13, 2009, 04:12:42 am »
So I am trying to make the screen draw two shaders, right? Here's the shader code in the Title Screen in Main.cpp of my repository(not committed yet):
Code: [Select]
       if (sf::Shader::IsAvailable()){
            Water.SetTexture("screen", sf::Shader::CurrentTexture);
            Water.SetParameter("time", Clock.GetElapsedTime()*1000.f);
            Blend.SetTexture("screen", sf::Shader::CurrentTexture);
            Blend.SetParameter("color", 0.5, 0.0, 0.5);
            Blend.SetParameter("alpha", 1.0);
            sf::RenderImage Screen;
            Screen.Draw(BG);
            Screen.Display();
            Window.Draw(sf::Sprite(Screen.GetImage()));
        }

Guess what? I just get a white screen. Why is this? When I replace the Window.Draw line with Window.Draw(BG); it works fine. When I use this code, it absolutely fails. What am I doing wrong? I'm drawing the BG to the RenderImage, Displaying the RenderImage, then drawing the RenderImage to the Screen, and I get White. :S
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #29 on: November 13, 2009, 08:21:44 am »
Quote
On the shader sample, global fisheye Y coordinates are flipped for me. It doesn't do this with background, and I can't tell on flower.

I know, this is a bug in the code of the shader.

Quote
Guess what? I just get a white screen. Why is this? When I replace the Window.Draw line with Window.Draw(BG); it works fine. When I use this code, it absolutely fails. What am I doing wrong? I'm drawing the BG to the RenderImage, Displaying the RenderImage, then drawing the RenderImage to the Screen, and I get White. :S

Your RenderImage instance gets destroyed after the call to Draw; but SFML delays the actual drawing until you call Window.Display(), and at this time the source image doesn't exist anymore.
Laurent Gomila - SFML developer