Agreed.nevon wrote:This so needs to find its way into Löve.
Shaders and FBOs
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Shaders and FBOs
Help us help you: attach a .love.
Re: Shaders and FBOs
This would be so cool for effects like, if a character dies the colors invert, etc. etc. etc! Awesome! Just AWESOME!
Re: Shaders and FBOs
How does one check for foreground color?you will need an fbo and then check for foreground color there
I want to be able to layer FBOs on top of each other, like stamps.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Shaders and FBOs
love.graphics.getColor()?ljdp wrote:How does one check for foreground color?
Help us help you: attach a .love.
Re: Shaders and FBOs
What I meant was:How does one check for foreground color?
- Render to fbo.
- Use fragment shader with fbo as alpha mask.
- ???
- Profit.
Re: Shaders and FBOs
Well I made a shader that makes black pixels transparent
Using this, and the glBlendFunc( GL_ZERO, GL_ONE_MINUS_SRC_ALPHA ) function I can make portal effects
like in ASCIIpOrtal.
Chect it out here: http://vimeo.com/14015078
It still needs work, especially how to deal with travelling through the portal.
I'll upload the source soon but I'll also need to give you the patch to add the extra blendmode constant.
Code: Select all
uniform sampler2D tex0;
void main(void)
{
vec4 col = texture2D(tex0, gl_TexCoord[0].st);
if(col[0] == 0.0 && col[1] == 0.0 && col[2] == 0.0)
{
col[3] = 0.0;
}
gl_FragColor = col;
}
like in ASCIIpOrtal.
Chect it out here: http://vimeo.com/14015078
It still needs work, especially how to deal with travelling through the portal.
I'll upload the source soon but I'll also need to give you the patch to add the extra blendmode constant.
Re: Shaders and FBOs
Anyone got a compiled windows version
Re: Shaders and FBOs
I still haven't gotten around to compiling this, because installing dev libs is teh bore. Sorry for almost promising I'd do it earlier in the thread...
I'd like to extend my wishes for Löve treating OpenGL in the same sensible and sane way that the SFML library does, for example. It provides helpful information that your computer does not support PostFX (its term for shader programs), instead of crashing mysteriously. Surely Löve devs will do the same and not just tell people with OpenGL 1.X implementations to go suck it. Right? Right??
You could, for example, install a virtualized OS with only software OpenGL support and test Löve regularly on it. Just so you will know it won't break for people with legacy hardware.
This is important for me because if I am going to publish some games with Löve (it remains a possiblity), I want as many people as possible to be able to enjoy them. I'm switching to something like SFML and Python for good otherwise.
I'd like to extend my wishes for Löve treating OpenGL in the same sensible and sane way that the SFML library does, for example. It provides helpful information that your computer does not support PostFX (its term for shader programs), instead of crashing mysteriously. Surely Löve devs will do the same and not just tell people with OpenGL 1.X implementations to go suck it. Right? Right??
You could, for example, install a virtualized OS with only software OpenGL support and test Löve regularly on it. Just so you will know it won't break for people with legacy hardware.
This is important for me because if I am going to publish some games with Löve (it remains a possiblity), I want as many people as possible to be able to enjoy them. I'm switching to something like SFML and Python for good otherwise.
Re: Shaders and FBOs
This is in no way meant to be complete nor part of the official LÖVE branch.
The Framebuffer object as seen here will fail gracefully (first trying to use >=OpenGL3 functions, then the extension and then telling it won't work). I think the same would be true for shaders.
The Framebuffer object as seen here will fail gracefully (first trying to use >=OpenGL3 functions, then the extension and then telling it won't work). I think the same would be true for shaders.
Re: Shaders and FBOs
I created a branch of the love mercurial repository called love-glsl. As you might have guessed this aims to include GLSL-Shader support to LÖVE.
It is based on the patch in this thread but has a different API:
status = love.graphics.hasShaders()
true if shaders are supported (GL version >= 2.0 and GL_ARB_shader_objects present)
version = love.graphics.getGLSLVersion()
Returns the GLSL version.
shader = love.graphics.newShader()
Creates a new Shader(-program, to be exact)
love.graphics.setShader( shader )
Sets the current shader to 'shader' or uses no shader if argument is nil or omitted. (equivalent to the previous program:use() and program:unuse())
status = Shader:addCode(type, code)
Adds shader code to the program.
type has to be one of 'vertex' or 'fragment' and determines the shader type (duh)
code has to be a string containing GLSL code
status is true if everything went fine, false otherwise. For how to get compile errors, see Shader:compile()
Shader:compile()
Tries to compile (actually link) the shader. Will throw an error with compiler and linker messages if anything went wrong.
log = Shader:infolog()
Returns the a string with error and warning messages of the compile process.
Shader:setUniform(name, u1, u2, u3, u4)
Sets the uniform value with name name to (u1,u2,u3,u4). u2 to u4 can be omitted.
The uniform type is assumed to be float.
Shader:setUniform(name, type, u1, u2, u3, u4)
Same as above, but with type either being "float" or "int".
Shader:setUniformMatrix(name, rows, cols, u1,u2,...u[rows*cols])
Sets a uniform matrix. You need to supply exactly rows*cols numbers.
Shader:setSampler(name, image, unit)
Sets uniform sampler ("uniform sampler2D") value to the texture of the Image object image.
unit can be omitted in which case it defaults to 0.
u1,u2,...,u16 = Shader:getSampler(name, type)
Returns the value of a named uniform. Unused values will be nan or 3735928559 if type is int.
type is either float or int but can be omitted in which case float is assumed.
I attached an updated version of the particles with shaders thing.
Please post any issues/feature requests to the bitbucket repo at http://bitbucket.org/vrld/love-glsl
It is based on the patch in this thread but has a different API:
status = love.graphics.hasShaders()
true if shaders are supported (GL version >= 2.0 and GL_ARB_shader_objects present)
version = love.graphics.getGLSLVersion()
Returns the GLSL version.
shader = love.graphics.newShader()
Creates a new Shader(-program, to be exact)
love.graphics.setShader( shader )
Sets the current shader to 'shader' or uses no shader if argument is nil or omitted. (equivalent to the previous program:use() and program:unuse())
status = Shader:addCode(type, code)
Adds shader code to the program.
type has to be one of 'vertex' or 'fragment' and determines the shader type (duh)
code has to be a string containing GLSL code
status is true if everything went fine, false otherwise. For how to get compile errors, see Shader:compile()
Shader:compile()
Tries to compile (actually link) the shader. Will throw an error with compiler and linker messages if anything went wrong.
log = Shader:infolog()
Returns the a string with error and warning messages of the compile process.
Shader:setUniform(name, u1, u2, u3, u4)
Sets the uniform value with name name to (u1,u2,u3,u4). u2 to u4 can be omitted.
The uniform type is assumed to be float.
Shader:setUniform(name, type, u1, u2, u3, u4)
Same as above, but with type either being "float" or "int".
Shader:setUniformMatrix(name, rows, cols, u1,u2,...u[rows*cols])
Sets a uniform matrix. You need to supply exactly rows*cols numbers.
Shader:setSampler(name, image, unit)
Sets uniform sampler ("uniform sampler2D") value to the texture of the Image object image.
unit can be omitted in which case it defaults to 0.
u1,u2,...,u16 = Shader:getSampler(name, type)
Returns the value of a named uniform. Unused values will be nan or 3735928559 if type is int.
type is either float or int but can be omitted in which case float is assumed.
I attached an updated version of the particles with shaders thing.
Please post any issues/feature requests to the bitbucket repo at http://bitbucket.org/vrld/love-glsl
- Attachments
-
- particles.love
- (18.22 KiB) Downloaded 165 times
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests