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.
-
pgimeno
- Party member
- Posts: 3550
- Joined: Sun Oct 18, 2015 2:58 pm
Post
by pgimeno »
I'm trying to use a shader to apply effects to a video, but when I set any shader, even the default shader, I get a blank video image.
Minimal example:
Code: Select all
local video = love.graphics.newVideo('video.ogv')
local shader = love.graphics.newShader[[
vec4 effect(vec4 colour, Image tex, vec2 texpos, vec2 scrpos)
{
return Texel(tex, texpos) * colour;
}
]]
video:play()
function love.draw()
love.graphics.setShader(shader)
love.graphics.draw(video)
love.graphics.setShader()
end
Is it possible to use a shader to filter a video? In this thread, bartbes seems to imply that it is, but I was unable:
https://love2d.org/forums/viewtopic.php ... deo+shader
-
Sasha264
- Party member
- Posts: 131
- Joined: Mon Sep 08, 2014 7:57 am
Post
by Sasha264 »
Hello!
I suggest that the problem is in Texel(...) function which is not intended to sample video.
Here I found proper sampling function for video:
https://love2d.org/wiki/love.graphics.newShader
Code: Select all
local video = love.graphics.newVideo('video.ogv')
local shader = love.graphics.newShader[[
vec4 effect(vec4 colour, Image tex, vec2 texpos, vec2 scrpos)
{
return vec4(1.0f, 1.0f, 1.0f, 2.0f) - VideoTexel(texpos) * colour;
}
]]
video:play()
function love.draw()
love.graphics.setShader(shader)
love.graphics.draw(video)
love.graphics.setShader()
end
vec4(1.0f, 1.0f, 1.0f, 2.0f) -
Does a simple inverse in my case.
-
pgimeno
- Party member
- Posts: 3550
- Joined: Sun Oct 18, 2015 2:58 pm
Post
by pgimeno »
Gah, you're so right, thank you! I haven't used video much yet as you can imagine
Users browsing this forum: Bing [Bot], keharriso, Semrush [Bot] and 214 guests