[SOLVED] How to do this visual 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.
User avatar
XHH
Citizen
Posts: 85
Joined: Thu Jun 20, 2013 6:43 pm
Location: US
Contact:

[SOLVED] How to do this visual effect?

Post by XHH »

I was watching this video of a game named Chroma:


There's a very cool wave effect at 0:08 and I was wondering if this can be done in Love2D.
Last edited by XHH on Wed Jul 10, 2013 11:50 am, edited 1 time in total.
I like to draw and program :)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [Question] How to do this visual effect?

Post by raidho36 »

Given that löve2d has shaders, everything is possible.

This is, I suppose, some sort of post-effect or something. It would, depending on pixel position relative to wave epicenter, sample texture (already rendered plain image) from a different point, closer or further than it actually would be, thus creating a warp effect.

If you don't know what shaders are and how to use them, I really suggest studying on that first before getting to do it.
User avatar
RedHot
Citizen
Posts: 87
Joined: Mon May 27, 2013 2:43 pm
Location: Poland

Re: [Question] How to do this visual effect?

Post by RedHot »

Instead of preaching generic and useless info I will try to get to the core.

Draw every frame to canvas, send canvas to a shader. Since Love2d doesn't provide a straight-forward access to Vertex Shader you can use the Fragment Shader called "Effect" in Love2d. In this very effect, use function called "Texel" when returning the pixel. It allows warping.

If you are a newbie that just wants the code you might get lucky cause I'm in the mood to share. Just give me some time to get my groceries ;)
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: [Question] How to do this visual effect?

Post by T-Bone »

Is it really necessary to render to a Canvas? Couldn't you just apply the shader directly?

I always thought you could use the "texture Image" argument to the main function in the shader to access different parts of what you're drawing. It doesn't seem to work now when I try it though.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: [Question] How to do this visual effect?

Post by raidho36 »

No, you can't do it that way, it needs to be post-processed.
I always thought you could use the "texture Image" argument to the main function in the shader to access different parts of what you're drawing.
That's correct. Just keep in mind that "what you're drawing" is your plain sprite, period. Nothing more than that.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: [Question] How to do this visual effect?

Post by T-Bone »

raidho36 wrote:No, you can't do it that way, it needs to be post-processed.
I always thought you could use the "texture Image" argument to the main function in the shader to access different parts of what you're drawing.
That's correct. Just keep in mind that "what you're drawing" is your plain sprite, period. Nothing more than that.
Oh, of course the shader is applied while you're drawing of course, not afterwards. Now everything makes sense.
User avatar
XHH
Citizen
Posts: 85
Joined: Thu Jun 20, 2013 6:43 pm
Location: US
Contact:

Re: [Question] How to do this visual effect?

Post by XHH »

I've done some basic stuff with shaders like inverting colors. So where can I find sample code demonstrating a warp effect?
I like to draw and program :)
User avatar
retrotails
Party member
Posts: 212
Joined: Wed Apr 18, 2012 12:37 am

Re: [Question] How to do this visual effect?

Post by retrotails »

XHH wrote:I've done some basic stuff with shaders like inverting colors. So where can I find sample code demonstrating a warp effect?
edit: Here's my example. Use arrow keys to adjust properties.
Bobbias
Prole
Posts: 36
Joined: Sat Jun 29, 2013 1:26 pm

Re: [Question] How to do this visual effect?

Post by Bobbias »

Oh cool. I haven't messed around with shaders yet, so this'll be a good example to take a look at when I do.
User avatar
XHH
Citizen
Posts: 85
Joined: Thu Jun 20, 2013 6:43 pm
Location: US
Contact:

Re: [Question] How to do this visual effect?

Post by XHH »

retrotails wrote:edit: Here's my example. Use arrow keys to adjust properties.
Thank you so much! Can't wait to start using this!
I like to draw and program :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests