Hey, I just tried applying a Blur Shader to a video, but insted of seing the video I just see some text.
Is this a limitation or did i do something wrong?
Shader on video
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Shader on video
Could you share a love file?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Shader on video
I Found this shader in the forums. I tried without the canvas first but that didn't work.Nixola wrote:Could you share a love file?
Code: Select all
video1 = love.graphics.newVideo("images/Wildlife.ogv",false),
blur1 = love.graphics.newShader [[
vec4 effect(vec4 color, Image texture, vec2 vTexCoord, vec2 pixel_coords)
{
vec4 sum = vec4(0.0);
number blurSize = 0.005;
//number d = distance(vTexCoord, mousePos/screenSize);
//number blurSize = clamp(1/d/screenSize.x, 0, 1.0);
// blur in y (vertical)
// take nine samples, with the distance blurSize between them
sum += texture2D(texture, vec2(vTexCoord.x - 4.0*blurSize, vTexCoord.y)) * 0.05;
sum += texture2D(texture, vec2(vTexCoord.x - 3.0*blurSize, vTexCoord.y)) * 0.09;
sum += texture2D(texture, vec2(vTexCoord.x - 2.0*blurSize, vTexCoord.y)) * 0.12;
sum += texture2D(texture, vec2(vTexCoord.x - blurSize, vTexCoord.y)) * 0.15;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y)) * 0.16;
sum += texture2D(texture, vec2(vTexCoord.x + blurSize, vTexCoord.y)) * 0.15;
sum += texture2D(texture, vec2(vTexCoord.x + 2.0*blurSize, vTexCoord.y)) * 0.12;
sum += texture2D(texture, vec2(vTexCoord.x + 3.0*blurSize, vTexCoord.y)) * 0.09;
sum += texture2D(texture, vec2(vTexCoord.x + 4.0*blurSize, vTexCoord.y)) * 0.05;
return sum;
}
]],
blur2 = love.graphics.newShader [[
vec4 effect(vec4 color, Image texture, vec2 vTexCoord, vec2 pixel_coords)
{
vec4 sum = vec4(0.0);
number blurSize = 0.005;
// blur in y (vertical)
// take nine samples, with the distance blurSize between them
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y - 4.0*blurSize)) * 0.05;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y - 3.0*blurSize)) * 0.09;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y - 2.0*blurSize)) * 0.12;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y- blurSize)) * 0.15;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y)) * 0.16;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y + blurSize)) * 0.15;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y + 2.0*blurSize)) * 0.12;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y + 3.0*blurSize)) * 0.09;
sum += texture2D(texture, vec2(vTexCoord.x, vTexCoord.y + 4.0*blurSize)) * 0.05;
return sum;
}
]]
Code: Select all
love.graphics.setCanvas(canvas)
love.graphics.setShader(images.blur1)
love.graphics.draw(images.video1,0,0,0,2,2)
love.graphics.setShader()
love.graphics.setCanvas()
love.graphics.setShader(images.blur2)
love.graphics.draw(canvas,0,0)
love.graphics.setShader()
- slime
- Solid Snayke
- Posts: 3159
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Shader on video
To get a pixel's color directly from a Video, you have to use VideoTexel(texcoord) instead of Texel/texture2D(texture, texcoord), since the Video object is not a Texture.
It might (or might not, I'm not sure) be more efficient to draw the Video to a Canvas without a shader. and then draw the Canvas to the screen (or to another Canvas) using your shader, rather than calling VideoTexel a bunch of times per pixel.
It might (or might not, I'm not sure) be more efficient to draw the Video to a Canvas without a shader. and then draw the Canvas to the screen (or to another Canvas) using your shader, rather than calling VideoTexel a bunch of times per pixel.
Last edited by slime on Thu Feb 25, 2016 11:26 pm, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Shader on video
VideoTexelslime wrote:TexelVideo(texcoord)
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests