Share a Shader!

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.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Share a Shader!

Post by scutheotaku »

Ref wrote:Try the attached demo (just something I stuck together from your code.).
The left image is created with bloom.
I think that this is the effect your are attempting???
Nope, I don't think so. Here's what it looks like for me:

Image


Just to be clear, the shader script I'm using is slime's, and, according to his example, should result in something like this:
u7JC0.png
u7JC0.png (117.22 KiB) Viewed 880 times
See his posts here:
viewtopic.php?f=4&t=3733&p=38666&hilit=bloom#p38565
And here:
viewtopic.php?f=4&t=3733&p=38666&hilit=bloom#p38666

And here's another example of a bloom effect (first picture is off, second picture is on):
http://www.progx.org/users/Gfx/aerith_bloom.png
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Share a Shader!

Post by Ref »

You might want to give this shader a try.

Code: Select all

bloom2 = love.graphics.newPixelEffect[[
   //BlackBulletIV
   extern vec2 size = vec2(20,20);
   extern int samples = 20; // pixels per axis; higher = bigger glow, worse performance
   extern float quality = .15; // lower = smaller glow, better quality

   vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc)
   {
      vec4 source = 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)) + source) * colour;
   }
]]
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Share a Shader!

Post by scutheotaku »

Ref wrote:You might want to give this shader a try.

Code: Select all

bloom2 = love.graphics.newPixelEffect[[
   //BlackBulletIV
   extern vec2 size = vec2(20,20);
   extern int samples = 20; // pixels per axis; higher = bigger glow, worse performance
   extern float quality = .15; // lower = smaller glow, better quality

   vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc)
   {
      vec4 source = 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)) + source) * colour;
   }
]]
Thanks again!

I had run across that before and, while the results look pretty good, its performance is pretty lacking, unfortunately...
User avatar
Taz
Prole
Posts: 11
Joined: Tue Feb 12, 2013 3:36 pm

Re: Share a Shader!

Post by Taz »

Hi,

I've written a little raytracer from scratch. It's not perfect and has some bugs like the shadow projection on the mirrored material, but I'm pretty happy with the result ;).

Controls:
W = Forward
S = Backward
A = Left Side
D = Right Side
B = Down
N = Up
Escape = exit the program

And for those who can't run glsl code :
Attachments
Raytracer.love
(3.37 KiB) Downloaded 295 times
raytracer.png
raytracer.png (24.7 KiB) Viewed 5002 times
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Share a Shader!

Post by scutheotaku »

Taz wrote:Hi,

I've written a little raytracer from scratch. It's not perfect and has some bugs like the shadow projection on the mirrored material, but I'm pretty happy with the result ;).

Controls:
W = Forward
S = Backward
A = Left Side
D = Right Side
B = Down
N = Up
Escape = exit the program

And for those who can't run glsl code :
Wow, excellent work!
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Share a Shader!

Post by raidho36 »

Displays me an error with shader location failure. I'm pretty sure my card Radeon HD 7970 can run GLSL.
User avatar
Taz
Prole
Posts: 11
Joined: Tue Feb 12, 2013 3:36 pm

Re: Share a Shader!

Post by Taz »

raidho36 wrote:Displays me an error with shader location failure. I'm pretty sure my card Radeon HD 7970 can run GLSL.
Actually I can't find a reason for this... can you post the exact error message ?
User avatar
jasonisop
Citizen
Posts: 93
Joined: Thu Jun 21, 2012 1:35 am

Re: Share a Shader!

Post by jasonisop »

Im getting an error as well.
graphics.lua:1346: Cannot get location of shader variable `light.direction'.
Acommon error is to define but not use the variable.

traceback
[C]: in function 'sendFloat'
graphics.lua:1346: in function 'send'
main.lua:102 in function 'update'
[C]: in function 'xpcall'


Edit: commenting out line 102 in main.lua allows it to run but im not sure the effect is the same.
User avatar
Taz
Prole
Posts: 11
Joined: Tue Feb 12, 2013 3:36 pm

Re: Share a Shader!

Post by Taz »

Ok that was my error :D forget to comment out the light direction but for some reasons the code still run with it .... Here's the (hopefully) fixed version.
Attachments
Raytracer.love
(3.4 KiB) Downloaded 333 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Share a Shader!

Post by raidho36 »

The yellow ball has reflections inside out, but other than that it's an "okay". I don't honestly understand why lövers are so obsessed with 3d and particularry with raytracing.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests