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.
- StoneCrow
- Party member
- Posts: 199
- Joined: Sat Apr 17, 2010 9:31 am
- Location: Wales the land of leeks and leaks
- Contact:
Re: Share a Shader!
Dont mind at all, its actually good to see how its supposed to work I havent got a very good grasp of love-glsl yet
Dull but sincere filler.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Share a Shader!
Oh, wow, that shader actually works on my computer! I thought none of them would work...Patalo wrote:Well, I took StoneCrow's code to finish the adaptation of the film effect (I hope you don't mind )
It works pretty well, I think I will take some parts for my project. The desaturation/illumination that comes with the grain is really cool.
EDIT: so far all of them work. :O
Last edited by Robin on Thu Jun 07, 2012 6:40 pm, edited 1 time in total.
Help us help you: attach a .love.
Re: Share a Shader!
Great!
Thanks for completing this.
Learning something with every example.
Thanks for completing this.
Learning something with every example.
Re: Share a Shader!
The film grain is very pretty! I love it.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
- AaronWizard
- Citizen
- Posts: 68
- Joined: Sun Nov 06, 2011 2:45 pm
- Location: Canada
Re: Share a Shader!
Simplex noise terrain generator, based on this project for GLSL noise.
There are two things I can't figure out though. One, I want the terrain to wrap horizontally and vertically for a preferably arbitrary pair of dimensions; e.g. the screen width and height. Two, I want to be able stick in a seed value somewhere (os.time() I guess) so that I can get different landscapes, plus different noise patterns to get things like rainfall. Both features apparently need lots of maths for me to implement even with regular simplex noise, not mentioning the GLSL optimized simplex noise code I copy-and-pasted.
There are two things I can't figure out though. One, I want the terrain to wrap horizontally and vertically for a preferably arbitrary pair of dimensions; e.g. the screen width and height. Two, I want to be able stick in a seed value somewhere (os.time() I guess) so that I can get different landscapes, plus different noise patterns to get things like rainfall. Both features apparently need lots of maths for me to implement even with regular simplex noise, not mentioning the GLSL optimized simplex noise code I copy-and-pasted.
- Attachments
-
- worldgen.love
- (2.83 KiB) Downloaded 397 times
Re: Share a Shader!
These effects are beautiful! I'm trying to create my first shader, but I still can't get my head around it. Are there any books or tutorials people can recommend?
Also, is there a way to apply a shader to everything on-screen? So far it seems to only apply to the way each of my individual objects are drawn.
(Edit: I think I answered my own question, you make a canvas object the size of the screen, draw all your stuff to it, apply a shader, then draw it to the screen. Right?)
Also, is there a way to apply a shader to everything on-screen? So far it seems to only apply to the way each of my individual objects are drawn.
(Edit: I think I answered my own question, you make a canvas object the size of the screen, draw all your stuff to it, apply a shader, then draw it to the screen. Right?)
Re: Share a Shader!
Or you cankexisse wrote:you make a canvas object the size of the screen, draw all your stuff to it, apply a shader, then draw it to the screen. Right?
Code: Select all
function love.load()
blank = love.graphics.newImage(love.graphics.newImageData(1, 1))
end
Code: Select all
function love.draw()
love.graphics.setPixelEffect(effect)
love.graphics.draw(blank, 0, 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
love.graphics.setPixelEffect()
end
For sure:kexisse wrote:Are there any books or tutorials people can recommend?
- glsl.heroku.com > 100 effects that are free to fork and learn from
- duh
- this thread. No, seriously the most helpful examples I've ever seen. I learned from totally zero.
Ah, I remember playing around with it. Very awesome code. About randomness I did it this way:AaronWizard wrote:Simplex noise terrain generator, based on this project for GLSL noise.
(Please note I don't completely remember)
Code: Select all
effect = love.graphics.newPixelEffect([[
extern number randx;
extern number randy;
vec4 effect(-some stuff-)
{
float x = -your coords- + randx;
float y = -your coords- + randx;
-your effect code-
}
]])
effect:send("randx", math.random()*100)
effect:send("randy", math.random()*100)
Code: Select all
effect = love.graphics.newPixelEffect([[
number randx = (]] .. math.random()*100 .. [[);
number randy = (]] .. math.random()*100 .. [[);
vec4 effect(-some stuff-)
{
float x = -your coords- + randx;
float y = -your coords- + randx;
-your effect code-
}
]])
- Mandarancio
- Prole
- Posts: 11
- Joined: Mon Nov 03, 2008 5:08 pm
- Location: Parma - Italy
- Contact:
Re: Share a Shader!
God-Rays shader
From http://fabiensanglard.net/lightScattering/index.php
External variable (play with this parametrs):
decay (~0.5-0.8)
density (~0.2-0.4)
weight (~0.5-2)
lightPositionOnScreen (vec2 with the position of the light [using texture coordinate (0.0-1.0,0.0-1.0)])
Enjoy!
From http://fabiensanglard.net/lightScattering/index.php
External variable (play with this parametrs):
decay (~0.5-0.8)
density (~0.2-0.4)
weight (~0.5-2)
lightPositionOnScreen (vec2 with the position of the light [using texture coordinate (0.0-1.0,0.0-1.0)])
Code: Select all
extern number decay;
extern number density;
extern number weight;
extern vec2 lightPositionOnScreen;
//uniform sampler2D firstPass;
const number NUM_SAMPLES = 100 ;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec2 deltaTextCoord = texture_coords - lightPositionOnScreen;
deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;
number illuminationDecay = 1.0;
vec2 textCoo=texture_coords;
vec4 result=texture2D(texture, textCoo );
for(int i=0; i < NUM_SAMPLES ; i++)
{
textCoo -= deltaTextCoord;
vec4 sample = texture2D(texture, textCoo );
sample *= illuminationDecay * weight;
result += sample;
illuminationDecay *= decay;
}
return result;
}
Arch Linux user..
..No Freedom without Sharing..
http://mandarancio.deviantart.com/
http://manda.netsons.org/
..No Freedom without Sharing..
http://mandarancio.deviantart.com/
http://manda.netsons.org/
Re: Share a Shader!
Thanks Mandarancio!
Hacked together a Love to try out all the parameters.
Not that easy to get the right combination so provided a random keyboard parameter selection - I know, no real no logic but at least I gave you a help screen and on-screen parameter setting display.
Found adding 'fog' made the effect a little more apparent.
Press <g> and <f> to toggle effects on/off.
Don't know exactly how you would use in a game but fun to play around with.
<New version of god_ray that doesn't recreate effect each cycle.>
Hacked together a Love to try out all the parameters.
Not that easy to get the right combination so provided a random keyboard parameter selection - I know, no real no logic but at least I gave you a help screen and on-screen parameter setting display.
Found adding 'fog' made the effect a little more apparent.
Press <g> and <f> to toggle effects on/off.
Don't know exactly how you would use in a game but fun to play around with.
<New version of god_ray that doesn't recreate effect each cycle.>
- Attachments
-
- god_ray.love
- Updated test script for god_ray
- (101.29 KiB) Downloaded 605 times
Re: Share a Shader!
Hi!
Anybody create a Sobel (edge detection) PixelEffect using the kernal:
1 2 1
0 0 0
-1 -2 -1
Anybody create a Sobel (edge detection) PixelEffect using the kernal:
1 2 1
0 0 0
-1 -2 -1
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 12 guests