[SOLVED] HOW TO MAKE RGB SPLIT EFFECT?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Darlex
Citizen
Posts: 64
Joined: Sun Sep 24, 2017 10:02 am
Location: somewhere hidden between
Contact:

[SOLVED] HOW TO MAKE RGB SPLIT EFFECT?

Post by Darlex » Sat Jan 19, 2019 12:47 am

Image
This is solved!
Last edited by Darlex on Sat Jan 19, 2019 3:33 pm, edited 1 time in total.
ERROR

User avatar
ivan
Party member
Posts: 1394
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: How i can do this effects on my games?

Post by ivan » Sat Jan 19, 2019 5:39 am

It's called chromatic abberation and can be achieved using shaders:

Code: Select all

// jangsy5 code
extern number aberration = 2.0;

vec4 effect(vec4 color, Image tx, vec2 tc, vec2 pc)
{
  // fake chromatic aberration
  float sx = aberration/love_ScreenSize.x;
  float sy = aberration/love_ScreenSize.y;
  vec4 r = Texel(tx, vec2(tc.x + sx, tc.y - sy));
  vec4 g = Texel(tx, vec2(tc.x, tc.y + sy));
  vec4 b = Texel(tx, vec2(tc.x - sx, tc.y - sy));
  number a = (r.a + g.a + b.a)/3.0;

  return vec4(r.r, g.g, b.b, a);
}

User avatar
Darlex
Citizen
Posts: 64
Joined: Sun Sep 24, 2017 10:02 am
Location: somewhere hidden between
Contact:

Re: How i can do this effects on my games?

Post by Darlex » Sat Jan 19, 2019 3:33 pm

ivan wrote:
Sat Jan 19, 2019 5:39 am
It's called chromatic abberation and can be achieved using shaders:

Code: Select all

// jangsy5 code
extern number aberration = 2.0;

vec4 effect(vec4 color, Image tx, vec2 tc, vec2 pc)
{
  // fake chromatic aberration
  float sx = aberration/love_ScreenSize.x;
  float sy = aberration/love_ScreenSize.y;
  vec4 r = Texel(tx, vec2(tc.x + sx, tc.y - sy));
  vec4 g = Texel(tx, vec2(tc.x, tc.y + sy));
  vec4 b = Texel(tx, vec2(tc.x - sx, tc.y - sy));
  number a = (r.a + g.a + b.a)/3.0;

  return vec4(r.r, g.g, b.b, a);
}
Wow! Thanks!
ERROR

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 47 guests