Well anyway, I want to focus back on the color equation that retrotails gave me so I can get a better understanding of how it tweens the transparency.
The equation was this:
cos(abs(mod(t,1) - .5)*3.14)
So basically what it does here is, first, gets the modulus of "t" and 1 and subtracts 0.5 from it. Then it takes the absolute value of "mod(t,1)-.5" and multiplies it by the first 3 integers of pi. And then it figures out the cosine of all that which equals the transparency. I'm just wondering how does that slowly change the transparency back in forth. I know that sin is used to create the wavy movement though.
Love2d GLSL Shaders
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Love2d GLSL Shaders
Check out my latest game: http://love2d.org/forums/viewtopic.php?f=5&t=33349
- retrotails
- Party member
- Posts: 212
- Joined: Wed Apr 18, 2012 12:37 am
Re: Love2d GLSL Shaders
"t" goes from 0 to 1 and repeats. If I subtract .5 it'll go from -.5 to .5. Then I make it absolute so it goes from .5 to 0 and back to .5, a smooth linear pulse. I take that and multiply it by pi just so I can have cosine smooth it.spynaz wrote:Well anyway, I want to focus back on the color equation that retrotails gave me so I can get a better understanding of how it tweens the transparency.
The equation was this:
cos(abs(mod(t,1) - .5)*3.14)
So basically what it does here is, first, gets the modulus of "t" and 1 and subtracts 0.5 from it. Then it takes the absolute value of "mod(t,1)-.5" and multiplies it by the first 3 integers of pi. And then it figures out the cosine of all that which equals the transparency. I'm just wondering how does that slowly change the transparency back in forth. I know that sin is used to create the wavy movement though.
Re: Love2d GLSL Shaders
Oh I get it now.
Check out my latest game: http://love2d.org/forums/viewtopic.php?f=5&t=33349
- xXxMoNkEyMaNxXx
- Party member
- Posts: 206
- Joined: Thu Jan 10, 2013 6:16 am
- Location: Canada
Re: Love2d GLSL Shaders
Squaring or square-rooting transparencies looks the best (I can't remember which)
Re: Love2d GLSL Shaders
What's the difference?
Check out my latest game: http://love2d.org/forums/viewtopic.php?f=5&t=33349
- xXxMoNkEyMaNxXx
- Party member
- Posts: 206
- Joined: Thu Jan 10, 2013 6:16 am
- Location: Canada
Re: Love2d GLSL Shaders
It looks better...
I should be square rooting that looks good, of my ambiguous post of last.
I should be square rooting that looks good, of my ambiguous post of last.
Re: Love2d GLSL Shaders
Ok. Well I only used this transparency effect just to learn a bit more so that I could start creating my own. I already know what I can do with color, but I still need to know what the rest of the things are used for.
So I'm guessing with "texture_coords" you change the position of the rectangle and with "pixel_coords" you change how pixelated it is?
So I'm guessing with "texture_coords" you change the position of the rectangle and with "pixel_coords" you change how pixelated it is?
Check out my latest game: http://love2d.org/forums/viewtopic.php?f=5&t=33349
- retrotails
- Party member
- Posts: 212
- Joined: Wed Apr 18, 2012 12:37 am
Re: Love2d GLSL Shaders
texture_coords.xyz gives you the position of the pixel in the loop on the texture. You can use that to modify UV coordinates however.spynaz wrote:Ok. Well I only used this transparency effect just to learn a bit more so that I could start creating my own. I already know what I can do with color, but I still need to know what the rest of the things are used for.
So I'm guessing with "texture_coords" you change the position of the rectangle and with "pixel_coords" you change how pixelated it is?
Code: Select all
vec2 uv = vec2(
texture_coords.x,
texture_coords.y
);
vec3 col = vec3(
texture2D(tex0,uv).x,
texture2D(tex0,uv).y,
texture2D(tex0,uv).z
);
The vec3() holds color information with x=r, y=g, z=b.
You can also modify all 3 at once with something like 'col += .5'
pixel_coords are the same as texture_coords except it gives you the pixel instead of a number between 0 and 1.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Love2d GLSL Shaders
To make your code not make me cringe:
Code: Select all
vec2 uv = texture_coords.xy;
vec3 col = texture2D(tex0, uv).rgb;
- retrotails
- Party member
- Posts: 212
- Joined: Wed Apr 18, 2012 12:37 am
Re: Love2d GLSL Shaders
eh, I copy and paste it and do a few things like invert texture_coords.y, add a noise function at different strengths for each color etc. then I cut it down.bartbes wrote:To make your code not make me cringe:Code: Select all
vec2 uv = texture_coords.xy; vec3 col = texture2D(tex0, uv).rgb;
Who is online
Users browsing this forum: Bing [Bot] and 7 guests