Somebody got a working bloom shader for 0.9.1? I can't get the stuff to work that's around here
Especially this does just nothing
Share a Shader!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Bloom for 0.9.1?
macOS 10.14 Mojave | LÖVE 11.2
- CaptainMaelstrom
- Party member
- Posts: 161
- Joined: Sat Jan 05, 2013 10:38 pm
Re: Share a Shader!
This should work. Credit to BlackBulletIV.
Code: Select all
shaders.bloom = lg.newShader[[
//BlackBulletIV
extern vec2 size = vec2(20,20);
extern int samples = 2; // pixels per axis; higher = bigger glow, worse performance
extern float quality = .5; // lower = smaller glow, better quality
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 sc)
{
vec4 src = Texel(tex, tc);
vec4 sum = vec4(0);
int diff = (samples - 1) / 2;
vec2 sizeFactor = vec2(1) / size * quality;
for (int x = -diff; x <= diff; x++)
{
for (int y = -diff; y <= diff; y++)
{
vec2 offset = vec2(x, y) * sizeFactor;
sum += Texel(tex, tc + offset);
}
}
return ((sum / (samples * samples)) + src) * color;
}
]]
Re: Share a Shader!
My whole computer freezes when I use it
Yes, my graphic card does support shaders.
Yes, my graphic card does support shaders.
macOS 10.14 Mojave | LÖVE 11.2
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Share a Shader!
I'm having trouble finding good rich in-depth tutorials for shaders. You could say they're... a Shady Business.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: Share a Shader!
It is difficult, getting started. But download some of the examples in this thread and learn from them (I think there was a few simpler image-manipulation demos towars the beginning).
I assume you've read the introduction to shaders?
Apart from that, go read some glsl (fragment) shader tutorials. Apart from the main function call's name and the "uniform" keyword, they're pretty much exactly what Löve shaders do.
I assume you've read the introduction to shaders?
Apart from that, go read some glsl (fragment) shader tutorials. Apart from the main function call's name and the "uniform" keyword, they're pretty much exactly what Löve shaders do.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Share a Shader!
Created a simple terrain generator along with lighting.
And here's the code for the normal map generator and shader.
And here's the code for the normal map generator and shader.
Code: Select all
function drawNormals(data)
local normals = love.image.newImageData(800, 600)
local sqrt = math.sqrt
local floor = math.floor
local a = 50
for y=1, 600-2 do
for x=1, 800-2 do
local s1, s2 = data:getPixel(x-1, y)
local s3, s4 = data:getPixel(x+1, y)
local v1 = s1*s2/65025 -- these multiplications are basically calculating
local v2 = s3*s4/65025 -- the final height value of my heightmap.
s1, s2 = data:getPixel(x, y-1)
s3, s4 = data:getPixel(x, y+1)
local v3 = s1*s2/65025 -- the height values are stored in two channels
local v4 = s3*s4/65025 -- first is the (red) details of the terrain,
local s5, s6 = data:getPixel(x, y) -- next is the (green) overall shape, including mountains.
local xgrad = a*(v1-v2) -- calculate the gradients by finding the difference between
local ygrad = a*(v3-v4) -- the two height valaues
local d = sqrt(xgrad*xgrad+ygrad*ygrad+1) -- normalize it
xgrad = xgrad/d
ygrad = ygrad/d
local z = 1/d
normals:setPixel(x, y, floor(xgrad*128+128), floor(ygrad*128+128), z*255, 255) -- store the normals
end
end
return normals
end
Code: Select all
extern vec2 screen = vec2(800.0f, 600.0f);
extern vec2 sundir = vec2(0.0f, 0.0f);
extern Image colormap;
const float sunheight = 1.0f;
const vec3 terrain = vec3(0.0f, 0.7f, 0.0f);
const vec3 ambient = vec3(0.01f, 0.0f, 0.015f);
// assume color is green for now
vec4 effect(vec4 color, Image texture, vec2 texcoords, vec2 pixcoords) {
// source color
vec4 source = Texel(texture, texcoords);
vec3 sunvector = normalize(vec3(sundir, -sunheight));
vec3 normal = normalize(source.rgb-vec3(0.5f, 0.5f, 0.5f));
vec4 data = Texel(colormap, texcoords);
float height = (data.r*data.g);
float l = dot(normal, -sunvector)*0.5f +0.5f;
l *= 1/((sunheight-height)*0.7f+1);
vec4 texcolor = vec4(terrain*l+ambient, 1.0f);
return texcolor * color;
}
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Share a Shader!
Alright... So I'm having problems with transferring openGL's GLSL globals like gl_NormalMatrix and gl_Normal.
It's really confusing having things renamed to... "Be made easier for coding" when it's making it more of a pain to learn the stuff. Although if I ever get GLSL Love enchanced version down, I'm sure I would appreciate having the globals not me huge names with a bunch of underscores and the like.
It would be a lot nicer if Love had on it's wiki page with global variables the variables' equivalent to GLSL variables. Or if someone would make a video tutorial on Love's version of GLSL. I'd be willing to do it, although of course I'm have variable problems. Which is one of the last things I want.
Sorry if I'm being blunt. Just frustrated when I can't figure things out.
It's really confusing having things renamed to... "Be made easier for coding" when it's making it more of a pain to learn the stuff. Although if I ever get GLSL Love enchanced version down, I'm sure I would appreciate having the globals not me huge names with a bunch of underscores and the like.
It would be a lot nicer if Love had on it's wiki page with global variables the variables' equivalent to GLSL variables. Or if someone would make a video tutorial on Love's version of GLSL. I'd be willing to do it, although of course I'm have variable problems. Which is one of the last things I want.
Sorry if I'm being blunt. Just frustrated when I can't figure things out.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Share a Shader!
[wiki]Shader Variables[/wiki] and Shader Language... this?
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- Zilarrezko
- Party member
- Posts: 345
- Joined: Mon Dec 10, 2012 5:50 am
- Location: Oregon
Re: Share a Shader!
Nah I've already looked through those. I mean something that shows something like what Shader Language does with all the "sampler2D is image", except for all of love's shader variables. I would make a better example but unfortunatly if I knew which GLSL variables corresponded to love's variables then I wouldn't be asking this question.Positive07 wrote:[wiki]Shader Variables[/wiki] and Shader Language... this?
Re: Share a Shader!
Love's default shaders are actually open-source! You can just look at the whole shader program yourself here: https://bitbucket.org/rude/love/src/585 ... ua#cl-1294
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests