Page 19 of 33

Re: Share a Shader!

Posted: Wed Jun 19, 2013 1:27 am
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 762 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

Re: Share a Shader!

Posted: Wed Jun 19, 2013 2:50 am
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;
   }
]]

Re: Share a Shader!

Posted: Wed Jun 19, 2013 3:49 am
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...

Re: Share a Shader!

Posted: Fri Jun 21, 2013 4:07 pm
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 :

Re: Share a Shader!

Posted: Fri Jun 21, 2013 4:47 pm
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!

Re: Share a Shader!

Posted: Fri Jun 21, 2013 5:07 pm
by raidho36
Displays me an error with shader location failure. I'm pretty sure my card Radeon HD 7970 can run GLSL.

Re: Share a Shader!

Posted: Fri Jun 21, 2013 6:10 pm
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 ?

Re: Share a Shader!

Posted: Fri Jun 21, 2013 6:14 pm
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.

Re: Share a Shader!

Posted: Fri Jun 21, 2013 6:24 pm
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.

Re: Share a Shader!

Posted: Fri Jun 21, 2013 6:32 pm
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.