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

Author Topic: SFML 1.5 PostFX problem ( ATI vs. Nvidia )  (Read 3290 times)

0 Members and 1 Guest are viewing this topic.

RixCoder

  • Newbie
  • *
  • Posts: 40
    • View Profile
SFML 1.5 PostFX problem ( ATI vs. Nvidia )
« on: August 29, 2009, 10:40:02 pm »
I have a problem going on right now and im sure its not an issue with sfml exactly but rather compiler differences between ATI and Nvidia for handling shaders.

But maybe someone here can point out a potential solution.

Right now I have the following FX code:
Code: [Select]

texture framebuffer
vec2 centerXY
float offset

effect
{
float len = distance(_in, centerXY) * offset;
if (len < (0.3f) && len > 0.1f)
_out = framebuffer(_in + (_in - centerXY) * len);
else
_out = framebuffer(_in);
}


now, centerXY is the ship's position being passed in and offset is the rate of expansion of a "shockwave" effect.

On an radeon mobility x1600 the shockwave effect works perfectly but position information is wonky, it offsets itself above where it should be spawning ( so its offset in the Y by an incorrect amount )

On an nvidia geforce go 7400 the effect comes out oval in shape but renders in the correct position always.

Its really hard finding information on this anywhere and it seems even having comments in one shader file works on the nvidia card but not the ATI card :shock: .

If anyone can help with this it would be greatly appreciated. Thanks in advance  :D

Jaenis

  • Newbie
  • *
  • Posts: 48
    • View Profile
SFML 1.5 PostFX problem ( ATI vs. Nvidia )
« Reply #1 on: August 30, 2009, 04:15:34 am »
Just a hunch...
I would think that distance() function is to blame. It has to use sqrt to get the distance, which is quite power hungry function, so card manufacturers might have done some weird optimizations to it.

Try something like this instead:
Code: [Select]

texture framebuffer
vec2 centerXY
float offset

effect
{
   float len = dot(_in, centerXY) * offset;
   if ((len < 0.09f) && (len > 0.01f))
      _out = framebuffer(_in + (_in - centerXY) * len);  
   else
      _out = framebuffer(_in);
}


I replaced the distance function with dot product, which does basically the same, but does not use sqrt:
  dot = x*x + y*y
  distance = sqrt( x*x + y*y )

Since square root was not used, those lengths you compare against had to be changed too:
  0.3 * 0.3 = 0.09
  0.1 * 0.1 = 0.01

RixCoder

  • Newbie
  • *
  • Posts: 40
    • View Profile
SFML 1.5 PostFX problem ( ATI vs. Nvidia )
« Reply #2 on: August 30, 2009, 06:33:28 pm »
That only wound up shifting the spawn of the effect into the lower left corner. Its meant to explode out of the player right now who moves around on the screen in all directions.

I tested it also on my home machine and the effect worked flawlessly on my gtx280, just can't get it looking right under this ati card I have in my laptop. I havn't tried it out on any newer ati cards though.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
SFML 1.5 PostFX problem ( ATI vs. Nvidia )
« Reply #3 on: September 01, 2009, 08:58:02 pm »
Jaenis' solution forgot to take into account the offset variable in len and the fact that len is used elsewhere in the code.  There's no way that could've worked right.

I'm not quite sure what to tell you about the drivers though.

 

anything